Fixup warnings from merge about undefined macro values, switch to

VM keyboard exception and switch to FATFS reader.
crypto-aes
Scott Shawcroft 6 years ago
parent dfb61f01db
commit cea5503ca0

@ -197,6 +197,7 @@ SRC_C = \
lib/fatfs/ff.c \
lib/fatfs/option/ccsbcs.c \
lib/timeutils/timeutils.c \
lib/utils/interrupt_char.c \
lib/utils/pyexec.c \
lib/utils/pyhelp.c \
lib/utils/stdout_helpers.c \

@ -27,23 +27,22 @@
#include "autoreset.h"
#include "asf/sam0/drivers/tc/tc_interrupt.h"
#include "lib/utils/interrupt_char.h"
#include "py/mphal.h"
void mp_keyboard_interrupt(void);
volatile uint32_t autoreset_delay_ms = 0;
bool autoreset_enabled = false;
volatile bool reset_next_character = false;
inline void autoreset_tick() {
if (autoreset_delay_ms == 0) {
return;
}
if (autoreset_delay_ms == 1 && autoreset_enabled && !reset_next_character) {
mp_keyboard_interrupt();
reset_next_character = true;
}
autoreset_delay_ms--;
if (autoreset_delay_ms == 0) {
return;
}
if (autoreset_delay_ms == 1 && autoreset_enabled && !reset_next_character) {
mp_keyboard_interrupt();
reset_next_character = true;
}
autoreset_delay_ms--;
}
void autoreset_enable() {

@ -125,8 +125,6 @@ void reset_mp(void) {
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash));
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash_slash_lib));
mp_obj_list_init(mp_sys_argv, 0);
MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
}
#ifdef EXPRESS_BOARD
@ -480,16 +478,6 @@ void gc_collect(void) {
gc_collect_end();
}
mp_lexer_t *fat_vfs_lexer_new_from_file(const char *filename);
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
#if MICROPY_VFS_FAT
return fat_vfs_lexer_new_from_file(filename);
#else
(void)filename;
return NULL;
#endif
}
mp_import_stat_t fat_vfs_import_stat(const char *path);
mp_import_stat_t mp_import_stat(const char *path) {
#if MICROPY_VFS_FAT
@ -500,10 +488,6 @@ mp_import_stat_t mp_import_stat(const char *path) {
#endif
}
void mp_keyboard_interrupt(void) {
MP_STATE_VM(mp_pending_exception) = MP_STATE_PORT(mp_kbd_exception);
}
void nlr_jump_fail(void *val) {
}

@ -86,9 +86,12 @@
#define MICROPY_USE_INTERNAL_PRINTF (1)
#define MICROPY_PY_SYS_STDFILES (1)
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_READER_FATFS (1)
#define MICROPY_PERSISTENT_CODE_LOAD (1)
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
#define MICROPY_KBD_EXCEPTION (1)
// type definitions for the specific machine
#define BYTES_PER_WORD (4)
@ -172,7 +175,6 @@ extern const struct _mp_obj_module_t samd_module;
#define MICROPY_PORT_ROOT_POINTERS \
const char *readline_hist[8]; \
vstr_t *repl_line; \
mp_obj_t mp_kbd_exception; \
FLASH_ROOT_POINTERS \
bool udi_msc_process_trans(void);

@ -8,6 +8,7 @@
#include "asf/sam0/drivers/port/port.h"
#include "asf/sam0/drivers/sercom/usart/usart.h"
#include "lib/mp-readline/readline.h"
#include "lib/utils/interrupt_char.h"
#include "py/mphal.h"
#include "py/mpstate.h"
#include "py/smallint.h"
@ -34,9 +35,6 @@ volatile uint8_t usb_rx_count;
volatile bool mp_cdc_enabled = false;
void mp_keyboard_interrupt(void);
int interrupt_char;
extern struct usart_module usart_instance;
static volatile bool mp_msc_enabled = false;
@ -106,7 +104,7 @@ void usb_rx_notify(void)
// character!
c = udi_cdc_getc();
if (c == interrupt_char) {
if (c == mp_interrupt_char) {
// We consumed a character rather than adding it to the rx
// buffer so undo the modifications we made to count and the
// tail.
@ -219,14 +217,6 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
#endif
}
extern int interrupt_char;
void mp_hal_set_interrupt_char(int c) {
if (c != -1) {
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
}
interrupt_char = c;
}
void mp_hal_delay_ms(mp_uint_t delay) {
// If mass storage is enabled measure the time ourselves and run any mass
// storage transactions in the meantime.
@ -239,7 +229,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
MICROPY_VM_HOOK_LOOP
#endif
// Check to see if we've been CTRL-Ced by autoreset or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_STATE_PORT(mp_kbd_exception)) {
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) {
break;
}
duration = (common_hal_time_monotonic() - start_tick);

@ -353,7 +353,7 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
int cx1 = x1;
for (int cx0 = x0; cx0 < x0end; ++cx0) {
color = getpixel(source, cx1, y1);
if (color != key) {
if (key == -1 || color != (uint32_t)key) {
setpixel(self, cx0, y0, color);
}
++cx1;

@ -122,7 +122,7 @@ void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label);
void asm_arm_b_label(asm_arm_t *as, uint label);
void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp);
#if GENERIC_ASM_API
#ifdef GENERIC_ASM_API
// The following macros provide a (mostly) arch-independent API to
// generate native code, and are used by the native emitter.

@ -237,7 +237,7 @@ void asm_thumb_b_label(asm_thumb_t *as, uint label); // convenience: picks narro
void asm_thumb_bcc_label(asm_thumb_t *as, int cc, uint label); // convenience: picks narrow or wide branch
void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp); // convenience
#if GENERIC_ASM_API
#ifdef GENERIC_ASM_API
// The following macros provide a (mostly) arch-independent API to
// generate native code, and are used by the native emitter.

@ -114,7 +114,7 @@ void asm_x64_mov_r64_to_local(asm_x64_t* as, int src_r64, int dest_local_num);
void asm_x64_mov_local_addr_to_r64(asm_x64_t* as, int local_num, int dest_r64);
void asm_x64_call_ind(asm_x64_t* as, void* ptr, int temp_r32);
#if GENERIC_ASM_API
#ifdef GENERIC_ASM_API
// The following macros provide a (mostly) arch-independent API to
// generate native code, and are used by the native emitter.

@ -112,7 +112,7 @@ void asm_x86_mov_r32_to_local(asm_x86_t* as, int src_r32, int dest_local_num);
void asm_x86_mov_local_addr_to_r32(asm_x86_t* as, int local_num, int dest_r32);
void asm_x86_call_ind(asm_x86_t* as, void* ptr, mp_uint_t n_args, int temp_r32);
#if GENERIC_ASM_API
#ifdef GENERIC_ASM_API
// The following macros provide a (mostly) arch-independent API to
// generate native code, and are used by the native emitter.

@ -239,7 +239,7 @@ void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src);
void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num);
void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num);
#if GENERIC_ASM_API
#ifdef GENERIC_ASM_API
// The following macros provide a (mostly) arch-independent API to
// generate native code, and are used by the native emitter.

@ -28,6 +28,7 @@
#define __MICROPY_INCLUDED_PY_MPERRNO_H__
#include "py/mpconfig.h"
#include "py/obj.h"
#if MICROPY_USE_INTERNAL_ERRNO

@ -148,18 +148,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(nativeio_uart___exit___obj, 4, 4, nat
//
//| .. method:: read([nbytes])
//|
//| Read characters. If ``nbytes`` is specified then read at most that many bytes.
//| Read characters. If ``nbytes`` is specified then read at most that many
//| bytes. Otherwise, read everything that has been buffered.
//|
//| :return: Data read
//| :rtype: bytes or None
//|
//| .. method:: readall()
//|
//| Reads much has been buffered.
//|
//| :return: Data buffered so far
//| :rtype: bytes or None
//|
//| .. method:: readinto(buf[, nbytes])
//|
//| Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
@ -263,7 +257,6 @@ STATIC const mp_rom_map_elem_t nativeio_uart_locals_dict_table[] = {
// Standard stream methods.
{ MP_OBJ_NEW_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_readall), MP_ROM_PTR(&mp_stream_readall_obj) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },

Loading…
Cancel
Save