Skip to content

Commit e757277

Browse files
robert-hhdpgeorge
authored andcommitted
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.
1 parent 99221cd commit e757277

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

drivers/dht/dht.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# DHT11/DHT22 driver for MicroPython on ESP8266
22
# MIT license; Copyright (c) 2016 Damien P. George
33

4-
try:
4+
import sys
5+
6+
if sys.platform.startswith("esp"):
57
from esp import dht_readinto
6-
except:
8+
elif sys.platform == "mimxrt":
9+
from mimxrt import dht_readinto
10+
else:
711
from pyb import dht_readinto
812

913

ports/mimxrt/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ SRC_C += \
213213
board_init.c \
214214
dma_channel.c \
215215
drivers/bus/softspi.c \
216+
drivers/dht/dht.c \
216217
eth.c \
217218
extmod/modnetwork.c \
218219
extmod/modonewire.c \

ports/mimxrt/boards/manifest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
freeze("$(PORT_DIR)/modules")
22
freeze("$(MPY_DIR)/drivers/onewire")
3+
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
34
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")

ports/mimxrt/modmimxrt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@
2424
* THE SOFTWARE.
2525
*/
2626

27+
#include "py/mperrno.h"
2728
#include "py/runtime.h"
29+
#include "drivers/dht/dht.h"
2830
#include "modmimxrt.h"
2931

3032
STATIC const mp_rom_map_elem_t mimxrt_module_globals_table[] = {
3133
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_mimxrt) },
3234
{ MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&mimxrt_flash_type) },
35+
36+
{ MP_ROM_QSTR(MP_QSTR_dht_readinto), MP_ROM_PTR(&dht_readinto_obj) },
3337
};
3438
STATIC MP_DEFINE_CONST_DICT(mimxrt_module_globals, mimxrt_module_globals_table);
3539

0 commit comments

Comments
 (0)