From d41f6dde568df53a0f66a01a3c362e1c1e35ef14 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 2 Sep 2021 12:39:50 +1000 Subject: [PATCH] extmod/modonewire: Make _onewire module configurable via macro option. Signed-off-by: Damien George --- extmod/modonewire.c | 4 ++++ ports/esp32/mpconfigport.h | 1 + ports/esp8266/mpconfigport.h | 1 + ports/mimxrt/mpconfigport.h | 1 + ports/rp2/mpconfigport.h | 1 + py/mpconfig.h | 5 +++++ 6 files changed, 13 insertions(+) diff --git a/extmod/modonewire.c b/extmod/modonewire.c index 6abe3dfad9..8b34268157 100644 --- a/extmod/modonewire.c +++ b/extmod/modonewire.c @@ -30,6 +30,8 @@ #include "py/obj.h" #include "py/mphal.h" +#if MICROPY_PY_ONEWIRE + /******************************************************************************/ // Low-level 1-Wire routines @@ -160,3 +162,5 @@ const mp_obj_module_t mp_module_onewire = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&onewire_module_globals, }; + +#endif // MICROPY_PY_ONEWIRE diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index f8b26bfe84..b306be937d 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -182,6 +182,7 @@ #define MICROPY_PY_WEBREPL (1) #define MICROPY_PY_FRAMEBUF (1) #define MICROPY_PY_BTREE (1) +#define MICROPY_PY_ONEWIRE (1) #define MICROPY_PY_USOCKET_EVENTS (MICROPY_PY_WEBREPL) #define MICROPY_PY_BLUETOOTH_RANDOM_ADDR (1) #define MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME ("ESP32") diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h index 5364dd58b5..78263efec5 100644 --- a/ports/esp8266/mpconfigport.h +++ b/ports/esp8266/mpconfigport.h @@ -86,6 +86,7 @@ #define MICROPY_PY_MACHINE_SPI (1) #define MICROPY_PY_MACHINE_SOFTSPI (1) #define MICROPY_PY_UWEBSOCKET (1) +#define MICROPY_PY_ONEWIRE (1) #define MICROPY_PY_WEBREPL (1) #define MICROPY_PY_WEBREPL_DELAY (20) #define MICROPY_PY_WEBREPL_STATIC_FILEBUF (1) diff --git a/ports/mimxrt/mpconfigport.h b/ports/mimxrt/mpconfigport.h index 88e1872cfc..be2b87e6a2 100644 --- a/ports/mimxrt/mpconfigport.h +++ b/ports/mimxrt/mpconfigport.h @@ -130,6 +130,7 @@ uint32_t trng_random_u32(void); #define MICROPY_PY_MACHINE_SPI (1) #define MICROPY_PY_MACHINE_SOFTSPI (1) #define MICROPY_PY_FRAMEBUF (1) +#define MICROPY_PY_ONEWIRE (1) // Use VfsLfs2's types for fileio/textio #define mp_type_fileio mp_type_vfs_lfs2_fileio diff --git a/ports/rp2/mpconfigport.h b/ports/rp2/mpconfigport.h index ad3de396b0..4da34cd038 100644 --- a/ports/rp2/mpconfigport.h +++ b/ports/rp2/mpconfigport.h @@ -138,6 +138,7 @@ #define MICROPY_PY_MACHINE_SPI_LSB (SPI_LSB_FIRST) #define MICROPY_PY_MACHINE_SOFTSPI (1) #define MICROPY_PY_FRAMEBUF (1) +#define MICROPY_PY_ONEWIRE (1) #define MICROPY_VFS (1) #define MICROPY_VFS_LFS2 (1) #define MICROPY_VFS_FAT (1) diff --git a/py/mpconfig.h b/py/mpconfig.h index 288b105375..1b41b6bd0f 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1517,6 +1517,11 @@ typedef double mp_float_t; #define MICROPY_PY_BTREE (0) #endif +// Whether to provide the low-level "_onewire" module +#ifndef MICROPY_PY_ONEWIRE +#define MICROPY_PY_ONEWIRE (0) +#endif + /*****************************************************************************/ /* Hooks for a port to add builtins */