summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGlenn Ruben Bakke <glennbakke@gmail.com>2017-01-22 19:34:32 +0100
committerGlenn Ruben Bakke <glennbakke@gmail.com>2017-01-22 19:34:32 +0100
commit93a245136d3e471d816009e099b55167c5d42e32 (patch)
tree0bb18484a3f323095e18f9fab16f4e609d6fe1e0 /lib
parente02c90dca52ce5d8b46368e2131f05f377546c75 (diff)
parent9397583f6c99533fc4c0a2753126120a8552ba4c (diff)
Merge branch 'nrf52' into nrf5_no_sdk
Diffstat (limited to 'lib')
-rw-r--r--lib/libm/math.c13
-rw-r--r--lib/libm/thumb_vfp_sqrtf.c11
-rw-r--r--lib/utils/interrupt_char.c8
-rw-r--r--lib/utils/pyexec.c4
-rw-r--r--lib/utils/pyhelp.c85
-rw-r--r--lib/utils/pyhelp.h33
6 files changed, 23 insertions, 131 deletions
diff --git a/lib/libm/math.c b/lib/libm/math.c
index 7cbec5fb3..732049236 100644
--- a/lib/libm/math.c
+++ b/lib/libm/math.c
@@ -86,19 +86,6 @@ double __aeabi_dmul(double x , double y) {
#endif // defined(__thumb__)
-// TODO this needs a better way of testing for Thumb2 FP hardware
-#if defined(__thumb2__)
-
-float sqrtf(float x) {
- asm volatile (
- "vsqrt.f32 %[r], %[x]\n"
- : [r] "=t" (x)
- : [x] "t" (x));
- return x;
-}
-
-#endif
-
#ifndef NDEBUG
float copysignf(float x, float y) {
float_s_t fx={.f = x};
diff --git a/lib/libm/thumb_vfp_sqrtf.c b/lib/libm/thumb_vfp_sqrtf.c
new file mode 100644
index 000000000..12ffebf82
--- /dev/null
+++ b/lib/libm/thumb_vfp_sqrtf.c
@@ -0,0 +1,11 @@
+// an implementation of sqrtf for Thumb using hardware VFP instructions
+
+#include <math.h>
+
+float sqrtf(float x) {
+ asm volatile (
+ "vsqrt.f32 %[r], %[x]\n"
+ : [r] "=t" (x)
+ : [x] "t" (x));
+ return x;
+}
diff --git a/lib/utils/interrupt_char.c b/lib/utils/interrupt_char.c
index 3133d5c06..ab4efd911 100644
--- a/lib/utils/interrupt_char.c
+++ b/lib/utils/interrupt_char.c
@@ -31,11 +31,19 @@ int mp_interrupt_char;
void mp_hal_set_interrupt_char(int c) {
if (c != -1) {
+ #if MICROPY_KBD_EXCEPTION
+ mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
+ #else
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
+ #endif
}
mp_interrupt_char = c;
}
void mp_keyboard_interrupt(void) {
+ #if MICROPY_KBD_EXCEPTION
+ MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
+ #else
MP_STATE_VM(mp_pending_exception) = MP_STATE_PORT(mp_kbd_exception);
+ #endif
}
diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c
index 61cd5a98c..5e2f24298 100644
--- a/lib/utils/pyexec.c
+++ b/lib/utils/pyexec.c
@@ -229,7 +229,9 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
// reset friendly REPL
mp_hal_stdout_tx_str("\r\n");
mp_hal_stdout_tx_str("MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n");
+ #if MICROPY_PY_BUILTINS_HELP
mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");
+ #endif
goto input_restart;
} else if (ret == CHAR_CTRL_C) {
// break
@@ -378,7 +380,9 @@ int pyexec_friendly_repl(void) {
friendly_repl_reset:
mp_hal_stdout_tx_str("MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n");
+ #if MICROPY_PY_BUILTINS_HELP
mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");
+ #endif
// to test ctrl-C
/*
diff --git a/lib/utils/pyhelp.c b/lib/utils/pyhelp.c
deleted file mode 100644
index 30ff391c4..000000000
--- a/lib/utils/pyhelp.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013-2016 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <stdio.h>
-
-#include "lib/utils/pyhelp.h"
-
-STATIC void pyhelp_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
- mp_printf(MP_PYTHON_PRINTER, " ");
- mp_obj_print(name_o, PRINT_STR);
- mp_printf(MP_PYTHON_PRINTER, " -- ");
- mp_obj_print(value, PRINT_STR);
- mp_printf(MP_PYTHON_PRINTER, "\n");
-}
-
-// Helper for 1-argument form of builtin help
-//
-// Typically a port will define a help function thus:
-//
-// STATIC const char *const myport_help_text =
-// "Welcome to MicroPython!\n"
-// "\n"
-// "...information specific to this port e.g. modules available...";
-//
-// STATIC mp_obj_t myport_help(mp_uint_t n_args, const mp_obj_t *args) {
-// if (n_args == 0) {
-// printf("%s", myport_help_text);
-// } else {
-// pyhelp_print_obj(args[0]);
-// }
-// return mp_const_none;
-// }
-// MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_help_obj, 0, 1, myport_help);
-//
-void pyhelp_print_obj(const mp_obj_t obj) {
- // try to print something sensible about the given object
- mp_printf(MP_PYTHON_PRINTER, "object ");
- mp_obj_print(obj, PRINT_STR);
- mp_printf(MP_PYTHON_PRINTER, " is of type %s\n", mp_obj_get_type_str(obj));
-
- mp_map_t *map = NULL;
- if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) {
- map = mp_obj_dict_get_map(mp_obj_module_get_globals(obj));
- } else {
- mp_obj_type_t *type;
- if (MP_OBJ_IS_TYPE(obj, &mp_type_type)) {
- type = obj;
- } else {
- type = mp_obj_get_type(obj);
- }
- if (type->locals_dict != MP_OBJ_NULL && MP_OBJ_IS_TYPE(type->locals_dict, &mp_type_dict)) {
- map = mp_obj_dict_get_map(type->locals_dict);
- }
- }
- if (map != NULL) {
- for (uint i = 0; i < map->alloc; i++) {
- if (map->table[i].key != MP_OBJ_NULL) {
- pyhelp_print_info_about_object(map->table[i].key, map->table[i].value);
- }
- }
- }
-}
diff --git a/lib/utils/pyhelp.h b/lib/utils/pyhelp.h
deleted file mode 100644
index ee313ee37..000000000
--- a/lib/utils/pyhelp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013-2016 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#ifndef __MICROPY_INCLUDED_LIB_UTILS_PYHELP_H__
-#define __MICROPY_INCLUDED_LIB_UTILS_PYHELP_H__
-
-#include "py/obj.h"
-
-void pyhelp_print_obj(const mp_obj_t obj);
-
-#endif // __MICROPY_INCLUDED_LIB_UTILS_PYHELP_H__