summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2022-01-02 15:07:33 +0200
committerDamien George <damien@micropython.org>2022-01-06 14:00:03 +1100
commit908e4cf5c3e21c73877686aa233b3dfd49d9083c (patch)
tree869ca3ce3756619fbee64789fe8ba1db0116154f
parent01d9b7adde0ed14002a9d47434ebb633205d45c3 (diff)
rp2: Add support for DHT11 and DHT22 sensors.
-rw-r--r--drivers/dht/dht.py2
-rw-r--r--ports/rp2/CMakeLists.txt1
-rw-r--r--ports/rp2/boards/manifest.py1
-rw-r--r--ports/rp2/modrp2.c3
4 files changed, 7 insertions, 0 deletions
diff --git a/drivers/dht/dht.py b/drivers/dht/dht.py
index 322608990..9be23b3ae 100644
--- a/drivers/dht/dht.py
+++ b/drivers/dht/dht.py
@@ -7,6 +7,8 @@ if sys.platform.startswith("esp"):
from esp import dht_readinto
elif sys.platform == "mimxrt":
from mimxrt import dht_readinto
+elif sys.platform == "rp2":
+ from rp2 import dht_readinto
else:
from pyb import dht_readinto
diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index c2f808854..c87ccf0d6 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -79,6 +79,7 @@ set(MICROPY_SOURCE_LIB
set(MICROPY_SOURCE_DRIVERS
${MICROPY_DIR}/drivers/bus/softspi.c
+ ${MICROPY_DIR}/drivers/dht/dht.c
)
set(MICROPY_SOURCE_PORT
diff --git a/ports/rp2/boards/manifest.py b/ports/rp2/boards/manifest.py
index a45bbe066..b0e5e3155 100644
--- a/ports/rp2/boards/manifest.py
+++ b/ports/rp2/boards/manifest.py
@@ -1,4 +1,5 @@
freeze("$(PORT_DIR)/modules")
freeze("$(MPY_DIR)/drivers/onewire")
+freeze("$(MPY_DIR)/drivers/dht", "dht.py")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
diff --git a/ports/rp2/modrp2.c b/ports/rp2/modrp2.c
index 8009fa33f..15c61911d 100644
--- a/ports/rp2/modrp2.c
+++ b/ports/rp2/modrp2.c
@@ -25,6 +25,7 @@
*/
#include "py/runtime.h"
+#include "drivers/dht/dht.h"
#include "modrp2.h"
STATIC const mp_rom_map_elem_t rp2_module_globals_table[] = {
@@ -32,6 +33,8 @@ STATIC const mp_rom_map_elem_t rp2_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&rp2_flash_type) },
{ MP_ROM_QSTR(MP_QSTR_PIO), MP_ROM_PTR(&rp2_pio_type) },
{ MP_ROM_QSTR(MP_QSTR_StateMachine), MP_ROM_PTR(&rp2_state_machine_type) },
+
+ { MP_ROM_QSTR(MP_QSTR_dht_readinto), MP_ROM_PTR(&dht_readinto_obj) },
};
STATIC MP_DEFINE_CONST_DICT(rp2_module_globals, rp2_module_globals_table);