summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2017-01-10 15:57:04 -0800
committerScott Shawcroft <scott.shawcroft@gmail.com>2017-01-12 12:46:18 -0800
commitcea5503ca006c712c007ad6d38c140c4ac241638 (patch)
treee7312e65bd59a2f81d3ea7c42eee7b4832295d7c
parentdfb61f01dbd1d580ff11503f531bb5972cbbd433 (diff)
Fixup warnings from merge about undefined macro values, switch to
VM keyboard exception and switch to FATFS reader.
-rw-r--r--atmel-samd/Makefile1
-rw-r--r--atmel-samd/autoreset.c19
-rw-r--r--atmel-samd/main.c16
-rw-r--r--atmel-samd/mpconfigport.h4
-rw-r--r--atmel-samd/mphalport.c16
-rw-r--r--extmod/modframebuf.c2
-rw-r--r--py/asmarm.h2
-rw-r--r--py/asmthumb.h2
-rw-r--r--py/asmx64.h2
-rw-r--r--py/asmx86.h2
-rw-r--r--py/asmxtensa.h2
-rw-r--r--py/mperrno.h1
-rw-r--r--shared-bindings/nativeio/UART.c11
13 files changed, 25 insertions, 55 deletions
diff --git a/atmel-samd/Makefile b/atmel-samd/Makefile
index e6f7534a0..675a2c23f 100644
--- a/atmel-samd/Makefile
+++ b/atmel-samd/Makefile
@@ -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 \
diff --git a/atmel-samd/autoreset.c b/atmel-samd/autoreset.c
index 047e59259..3f6681938 100644
--- a/atmel-samd/autoreset.c
+++ b/atmel-samd/autoreset.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() {
diff --git a/atmel-samd/main.c b/atmel-samd/main.c
index 092af2bc9..89de725ec 100644
--- a/atmel-samd/main.c
+++ b/atmel-samd/main.c
@@ -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) {
}
diff --git a/atmel-samd/mpconfigport.h b/atmel-samd/mpconfigport.h
index 36ab4715e..b53b910bf 100644
--- a/atmel-samd/mpconfigport.h
+++ b/atmel-samd/mpconfigport.h
@@ -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);
diff --git a/atmel-samd/mphalport.c b/atmel-samd/mphalport.c
index 4ff4022ca..d65c89a63 100644
--- a/atmel-samd/mphalport.c
+++ b/atmel-samd/mphalport.c
@@ -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);
diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c
index d6e686e07..22841102f 100644
--- a/extmod/modframebuf.c
+++ b/extmod/modframebuf.c
@@ -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;
diff --git a/py/asmarm.h b/py/asmarm.h
index e273b98d7..8a114f8a9 100644
--- a/py/asmarm.h
+++ b/py/asmarm.h
@@ -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.
diff --git a/py/asmthumb.h b/py/asmthumb.h
index 52e663b3b..cedecba52 100644
--- a/py/asmthumb.h
+++ b/py/asmthumb.h
@@ -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.
diff --git a/py/asmx64.h b/py/asmx64.h
index 4499c53c3..3c2bbd006 100644
--- a/py/asmx64.h
+++ b/py/asmx64.h
@@ -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.
diff --git a/py/asmx86.h b/py/asmx86.h
index 0b44af663..be76b1ab7 100644
--- a/py/asmx86.h
+++ b/py/asmx86.h
@@ -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.
diff --git a/py/asmxtensa.h b/py/asmxtensa.h
index 12083252e..6cfe60237 100644
--- a/py/asmxtensa.h
+++ b/py/asmxtensa.h
@@ -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.
diff --git a/py/mperrno.h b/py/mperrno.h
index 328afddb1..88d95e566 100644
--- a/py/mperrno.h
+++ b/py/mperrno.h
@@ -28,6 +28,7 @@
#define __MICROPY_INCLUDED_PY_MPERRNO_H__
#include "py/mpconfig.h"
+#include "py/obj.h"
#if MICROPY_USE_INTERNAL_ERRNO
diff --git a/shared-bindings/nativeio/UART.c b/shared-bindings/nativeio/UART.c
index 3d0e7f475..c2cab4033 100644
--- a/shared-bindings/nativeio/UART.c
+++ b/shared-bindings/nativeio/UART.c
@@ -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) },