summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-12-02 13:10:39 -0800
committerScott Shawcroft <scott@tannewt.org>2020-12-02 13:10:39 -0800
commit608c98501bb90e02a480b2d84032a46f9a4d0737 (patch)
treeadea018a0c0e714ef33b79a306b69885568b6ad0 /py
parent34bbcc4910014c3b4646d8005baf8244bac51f03 (diff)
parentd7ba641ff646b48e5ad38ff72a2dcfe17bb54624 (diff)
Merge remote-tracking branch 'adafruit/main' into msgpack
Diffstat (limited to 'py')
-rw-r--r--py/circuitpy_defns.mk16
-rw-r--r--py/circuitpy_mpconfig.h9
-rw-r--r--py/circuitpy_mpconfig.mk6
-rw-r--r--py/enum.h4
-rw-r--r--py/genlast.py4
-rw-r--r--py/obj.h5
-rw-r--r--py/objexcept.c3
-rw-r--r--py/objfloat.c7
-rw-r--r--py/reload.c22
-rw-r--r--py/reload.h22
10 files changed, 84 insertions, 14 deletions
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index 8c452c2b0..f13f69bcf 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -99,6 +99,9 @@ endif
ifeq ($(CIRCUITPY_AESIO),1)
SRC_PATTERNS += aesio/%
endif
+ifeq ($(CIRCUITPY_ALARM),1)
+SRC_PATTERNS += alarm/%
+endif
ifeq ($(CIRCUITPY_ANALOGIO),1)
SRC_PATTERNS += analogio/%
endif
@@ -301,6 +304,9 @@ SRC_COMMON_HAL_ALL = \
_bleio/__init__.c \
_pew/PewPew.c \
_pew/__init__.c \
+ alarm/__init__.c \
+ alarm/pin/PinAlarm.c \
+ alarm/time/TimeAlarm.c \
analogio/AnalogIn.c \
analogio/AnalogOut.c \
analogio/__init__.c \
@@ -390,16 +396,18 @@ $(filter $(SRC_PATTERNS), \
_bleio/Address.c \
_bleio/Attribute.c \
_bleio/ScanEntry.c \
- canio/Match.c \
_eve/__init__.c \
camera/ImageFormat.c \
+ canio/Match.c \
digitalio/Direction.c \
digitalio/DriveMode.c \
digitalio/Pull.c \
fontio/Glyph.c \
math/__init__.c \
+ microcontroller/ResetReason.c \
microcontroller/RunMode.c \
msgpack/__init__.c \
+ supervisor/RunReason.c \
)
SRC_BINDINGS_ENUMS += \
@@ -410,9 +418,6 @@ SRC_SHARED_MODULE_ALL = \
_bleio/Attribute.c \
_bleio/ScanEntry.c \
_bleio/ScanResults.c \
- canio/Match.c \
- canio/Message.c \
- canio/RemoteTransmissionRequest.c \
_eve/__init__.c \
_pixelbuf/PixelBuf.c \
_pixelbuf/__init__.c \
@@ -437,6 +442,9 @@ SRC_SHARED_MODULE_ALL = \
bitbangio/__init__.c \
board/__init__.c \
busio/OneWire.c \
+ canio/Match.c \
+ canio/Message.c \
+ canio/RemoteTransmissionRequest.c \
displayio/Bitmap.c \
displayio/ColorConverter.c \
displayio/Display.c \
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index 64fedd506..f04241380 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -245,6 +245,13 @@ extern const struct _mp_obj_module_t aesio_module;
#define AESIO_MODULE
#endif
+#if CIRCUITPY_ALARM
+extern const struct _mp_obj_module_t alarm_module;
+#define ALARM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm), (mp_obj_t)&alarm_module },
+#else
+#define ALARM_MODULE
+#endif
+
#if CIRCUITPY_ANALOGIO
#define ANALOGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module },
extern const struct _mp_obj_module_t analogio_module;
@@ -609,7 +616,6 @@ extern const struct _mp_obj_module_t sdioio_module;
#define SDIOIO_MODULE
#endif
-
#if CIRCUITPY_SHARPDISPLAY
extern const struct _mp_obj_module_t sharpdisplay_module;
#define SHARPDISPLAY_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_sharpdisplay),(mp_obj_t)&sharpdisplay_module },
@@ -781,6 +787,7 @@ extern const struct _mp_obj_module_t msgpack_module;
// Some are omitted because they're in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS above.
#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \
AESIO_MODULE \
+ ALARM_MODULE \
ANALOGIO_MODULE \
AUDIOBUSIO_MODULE \
AUDIOCORE_MODULE \
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index 348a22cd4..8fd20d622 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -39,6 +39,12 @@ CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT)
CIRCUITPY_AESIO ?= 0
CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO)
+# TODO: CIRCUITPY_ALARM will gradually be added to
+# as many ports as possible
+# so make this 1 or CIRCUITPY_FULL_BUILD eventually
+CIRCUITPY_ALARM ?= 0
+CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM)
+
CIRCUITPY_ANALOGIO ?= 1
CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO)
diff --git a/py/enum.h b/py/enum.h
index 1c38ae5ae..708678eb6 100644
--- a/py/enum.h
+++ b/py/enum.h
@@ -35,12 +35,12 @@ typedef struct {
} cp_enum_obj_t;
#define MAKE_ENUM_VALUE(type, prefix, name, value) \
- STATIC const cp_enum_obj_t prefix ## _ ## name ## _obj = { \
+ const cp_enum_obj_t prefix ## _ ## name ## _obj = { \
{ &type }, value, MP_QSTR_ ## name, \
}
#define MAKE_ENUM_MAP(name) \
- STATIC const mp_rom_map_elem_t name ## _locals_table[] =
+ const mp_rom_map_elem_t name ## _locals_table[] =
#define MAKE_ENUM_MAP_ENTRY(prefix, name) \
{ MP_ROM_QSTR(MP_QSTR_ ## name), MP_ROM_PTR(&prefix ## _ ## name ## _obj) }
diff --git a/py/genlast.py b/py/genlast.py
index 1df2a2482..5b195d23e 100644
--- a/py/genlast.py
+++ b/py/genlast.py
@@ -47,7 +47,9 @@ def preprocess(command, output_dir, fn):
print(e, file=sys.stderr)
def maybe_preprocess(command, output_dir, fn):
- if subprocess.call(["grep", "-lqE", "(MP_QSTR|translate)", fn]) == 0:
+ # Preprocess the source file if it contains "MP_QSTR", "translate",
+ # or if it uses enum.h (which generates "MP_QSTR" strings.
+ if subprocess.call(["grep", "-lqE", r"(MP_QSTR|translate|enum\.h)", fn]) == 0:
preprocess(command, output_dir, fn)
if __name__ == '__main__':
diff --git a/py/obj.h b/py/obj.h
index 805b26e48..066562cc4 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -640,6 +640,10 @@ extern const mp_obj_type_t mp_type_UnicodeError;
extern const mp_obj_type_t mp_type_ValueError;
extern const mp_obj_type_t mp_type_ViperTypeError;
extern const mp_obj_type_t mp_type_ZeroDivisionError;
+#if CIRCUITPY_ALARM
+extern const mp_obj_type_t mp_type_DeepSleepRequest;
+#endif
+
// Constant objects, globally accessible
// The macros are for convenience only
@@ -679,6 +683,7 @@ mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items);
#if MICROPY_PY_BUILTINS_FLOAT
mp_obj_t mp_obj_new_int_from_float(mp_float_t val);
mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag);
+extern mp_float_t uint64_to_float(uint64_t ui64);
#endif
mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type);
mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg);
diff --git a/py/objexcept.c b/py/objexcept.c
index 01ba6da9c..afefee2ca 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -319,6 +319,9 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION(UnicodeError, ValueError)
//TODO: Implement more UnicodeError subclasses which take arguments
#endif
+#if CIRCUITPY_ALARM
+ MP_DEFINE_EXCEPTION(DeepSleepRequest, BaseException)
+#endif
MP_DEFINE_EXCEPTION(MpyError, ValueError)
/*
MP_DEFINE_EXCEPTION(Warning, Exception)
diff --git a/py/objfloat.c b/py/objfloat.c
index 59f1eb2f6..80f10e816 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -333,6 +333,13 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
return mp_obj_new_float(lhs_val);
}
+// Convert a uint64_t to a 32-bit float without invoking the double-precision math routines,
+// which are large.
+mp_float_t uint64_to_float(uint64_t ui64) {
+ // 4294967296 = 2^32
+ return (mp_float_t) ((uint32_t) (ui64 >> 32) * 4294967296.0f + (uint32_t) (ui64 & 0xffffffff));
+}
+
#pragma GCC diagnostic pop
#endif // MICROPY_PY_BUILTINS_FLOAT
diff --git a/py/reload.c b/py/reload.c
index 95305f2c9..f9f8a590a 100644
--- a/py/reload.c
+++ b/py/reload.c
@@ -1,6 +1,22 @@
-//
-// Created by Roy Hooper on 2018-05-14.
-//
+ /*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 by Roy Hooper
+ * 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 "reload.h"
#include "py/mpstate.h"
diff --git a/py/reload.h b/py/reload.h
index 72e84e5ca..3e8928a32 100644
--- a/py/reload.h
+++ b/py/reload.h
@@ -1,6 +1,22 @@
-//
-// Created by Roy Hooper on 2018-05-14.
-//
+ /*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 by Roy Hooper
+ * 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 CIRCUITPYTHON_RELOAD_H
#define CIRCUITPYTHON_RELOAD_H