From e7572776c3ec3a245c831f3f2aaa595a4dec43a8 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Sat, 19 Jun 2021 11:00:55 +0200 Subject: [PATCH] mimxrt: Add dht_readinto() to the mimxrt module, and freeze dht.py. The change affects dht.py from the drivers directory as well to include the logic for the mimxrt port. --- drivers/dht/dht.py | 8 ++++++-- ports/mimxrt/Makefile | 1 + ports/mimxrt/boards/manifest.py | 1 + ports/mimxrt/modmimxrt.c | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/dht/dht.py b/drivers/dht/dht.py index 1163b382bb..322608990e 100644 --- a/drivers/dht/dht.py +++ b/drivers/dht/dht.py @@ -1,9 +1,13 @@ # DHT11/DHT22 driver for MicroPython on ESP8266 # MIT license; Copyright (c) 2016 Damien P. George -try: +import sys + +if sys.platform.startswith("esp"): from esp import dht_readinto -except: +elif sys.platform == "mimxrt": + from mimxrt import dht_readinto +else: from pyb import dht_readinto diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index 239b7cd0c7..7cda558bdc 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -213,6 +213,7 @@ SRC_C += \ board_init.c \ dma_channel.c \ drivers/bus/softspi.c \ + drivers/dht/dht.c \ eth.c \ extmod/modnetwork.c \ extmod/modonewire.c \ diff --git a/ports/mimxrt/boards/manifest.py b/ports/mimxrt/boards/manifest.py index 9df589f126..ccbd33cae8 100644 --- a/ports/mimxrt/boards/manifest.py +++ b/ports/mimxrt/boards/manifest.py @@ -1,3 +1,4 @@ freeze("$(PORT_DIR)/modules") freeze("$(MPY_DIR)/drivers/onewire") +freeze("$(MPY_DIR)/drivers/dht", "dht.py") include("$(MPY_DIR)/extmod/uasyncio/manifest.py") diff --git a/ports/mimxrt/modmimxrt.c b/ports/mimxrt/modmimxrt.c index addd4ba4d2..041a72f7f7 100644 --- a/ports/mimxrt/modmimxrt.c +++ b/ports/mimxrt/modmimxrt.c @@ -24,12 +24,16 @@ * THE SOFTWARE. */ +#include "py/mperrno.h" #include "py/runtime.h" +#include "drivers/dht/dht.h" #include "modmimxrt.h" STATIC const mp_rom_map_elem_t mimxrt_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_mimxrt) }, { MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&mimxrt_flash_type) }, + + { MP_ROM_QSTR(MP_QSTR_dht_readinto), MP_ROM_PTR(&dht_readinto_obj) }, }; STATIC MP_DEFINE_CONST_DICT(mimxrt_module_globals, mimxrt_module_globals_table);