summaryrefslogtreecommitdiff
path: root/atmel-samd
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 /atmel-samd
parentdfb61f01dbd1d580ff11503f531bb5972cbbd433 (diff)
Fixup warnings from merge about undefined macro values, switch to
VM keyboard exception and switch to FATFS reader.
Diffstat (limited to 'atmel-samd')
-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
5 files changed, 16 insertions, 40 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);