diff --git a/drivers/dht/dht.py b/drivers/dht/dht.py deleted file mode 100644 index eed61df7c9..0000000000 --- a/drivers/dht/dht.py +++ /dev/null @@ -1,35 +0,0 @@ -# DHT11/DHT22 driver for MicroPython on ESP8266 -# MIT license; Copyright (c) 2016 Damien P. George - -try: - from esp import dht_readinto -except: - from pyb import dht_readinto - -class DHTBase: - def __init__(self, pin): - self.pin = pin - self.buf = bytearray(5) - - def measure(self): - buf = self.buf - dht_readinto(self.pin, buf) - if (buf[0] + buf[1] + buf[2] + buf[3]) & 0xff != buf[4]: - raise Exception("checksum error") - -class DHT11(DHTBase): - def humidity(self): - return self.buf[0] - - def temperature(self): - return self.buf[2] - -class DHT22(DHTBase): - def humidity(self): - return (self.buf[0] << 8 | self.buf[1]) * 0.1 - - def temperature(self): - t = ((self.buf[2] & 0x7f) << 8 | self.buf[3]) * 0.1 - if self.buf[2] & 0x80: - t = -t - return t diff --git a/extmod/modwebrepl.c b/extmod/modwebrepl.c index 48b49bfc4f..06da210d15 100644 --- a/extmod/modwebrepl.c +++ b/extmod/modwebrepl.c @@ -37,7 +37,7 @@ #include "extmod/modwebsocket.h" #include "genhdr/mpversion.h" -#ifdef MICROPY_PY_WEBREPL +#if MICROPY_PY_WEBREPL #if 0 // print debugging info #define DEBUG_printf DEBUG_printf diff --git a/extmod/uos_dupterm.c b/extmod/uos_dupterm.c index 0de26cbdd4..cc6d97f419 100644 --- a/extmod/uos_dupterm.c +++ b/extmod/uos_dupterm.c @@ -34,7 +34,7 @@ #include "py/stream.h" #include "lib/utils/interrupt_char.h" -#ifdef MICROPY_PY_OS_DUPTERM +#if MICROPY_PY_OS_DUPTERM void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc) { mp_obj_t term = MP_STATE_VM(dupterm_objs[dupterm_idx]); diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c index 6e3bb2c5bd..9ee4900ee2 100644 --- a/extmod/vfs_posix.c +++ b/extmod/vfs_posix.c @@ -29,7 +29,7 @@ #include "extmod/vfs.h" #include "extmod/vfs_posix.h" -#if MICROPY_VFS_POSIX +#if defined(MICROPY_VFS_POSIX) && MICROPY_VFS_POSIX #include #include diff --git a/extmod/vfs_posix.h b/extmod/vfs_posix.h index 00756b4c9d..32299b8269 100644 --- a/extmod/vfs_posix.h +++ b/extmod/vfs_posix.h @@ -27,6 +27,7 @@ #define MICROPY_INCLUDED_EXTMOD_VFS_POSIX_H #include "py/lexer.h" +#include "py/mpconfig.h" #include "py/obj.h" extern const mp_obj_type_t mp_type_vfs_posix; diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index 435ac65cd4..d3ed4fe217 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -28,7 +28,7 @@ #include "py/stream.h" #include "extmod/vfs_posix.h" -#if MICROPY_VFS_POSIX +#if defined(MICROPY_VFS_POSIX) && MICROPY_VFS_POSIX #include diff --git a/py/asmarm.h b/py/asmarm.h index fbfe09aacd..5603030912 100644 --- a/py/asmarm.h +++ b/py/asmarm.h @@ -122,7 +122,7 @@ void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label); void asm_arm_b_label(asm_arm_t *as, uint label); void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp); -#ifdef GENERIC_ASM_API +#if defined(GENERIC_ASM_API) && GENERIC_ASM_API // The following macros provide a (mostly) arch-independent API to // generate native code, and are used by the native emitter. diff --git a/py/asmthumb.h b/py/asmthumb.h index f8665f35cc..b7e2acc048 100644 --- a/py/asmthumb.h +++ b/py/asmthumb.h @@ -238,7 +238,7 @@ void asm_thumb_b_label(asm_thumb_t *as, uint label); // convenience: picks narro void asm_thumb_bcc_label(asm_thumb_t *as, int cc, uint label); // convenience: picks narrow or wide branch void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp); // convenience -#ifdef GENERIC_ASM_API +#if defined(GENERIC_ASM_API) && GENERIC_ASM_API // The following macros provide a (mostly) arch-independent API to // generate native code, and are used by the native emitter. diff --git a/py/asmx64.h b/py/asmx64.h index 9ed2a6cf95..ed0b785fb2 100644 --- a/py/asmx64.h +++ b/py/asmx64.h @@ -114,7 +114,7 @@ void asm_x64_mov_r64_to_local(asm_x64_t* as, int src_r64, int dest_local_num); void asm_x64_mov_local_addr_to_r64(asm_x64_t* as, int local_num, int dest_r64); void asm_x64_call_ind(asm_x64_t* as, void* ptr, int temp_r32); -#ifdef GENERIC_ASM_API +#if defined(GENERIC_ASM_API) && GENERIC_ASM_API // The following macros provide a (mostly) arch-independent API to // generate native code, and are used by the native emitter. diff --git a/py/asmxtensa.h b/py/asmxtensa.h index 13d3e82346..ef80f700a3 100644 --- a/py/asmxtensa.h +++ b/py/asmxtensa.h @@ -239,7 +239,7 @@ void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_src); void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local_num); void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int local_num); -#ifdef GENERIC_ASM_API +#if defined(GENERIC_ASM_API) && GENERIC_ASM_API // The following macros provide a (mostly) arch-independent API to // generate native code, and are used by the native emitter. diff --git a/py/modmath.c b/py/modmath.c index 56ceb14bd1..4fa36d3047 100644 --- a/py/modmath.c +++ b/py/modmath.c @@ -26,7 +26,6 @@ #include "py/builtin.h" #include "py/runtime.h" -#include "py/runtime.h" #if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH diff --git a/py/mpconfig.h b/py/mpconfig.h index 52a7c05a21..d80730809d 100755 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1238,6 +1238,22 @@ typedef double mp_float_t; #define MICROPY_PY_BTREE (0) #endif +#ifndef MICROPY_PY_OS_DUPTERM +#define MICROPY_PY_OS_DUPTERM (0) +#endif + +#ifndef MICROPY_PY_LWIP_SLIP +#define MICROPY_PY_LWIP_SLIP (0) +#endif + +#ifndef MICROPY_HW_ENABLE_USB +#define MICROPY_HW_ENABLE_USB (0) +#endif + +#ifndef MICROPY_PY_WEBREPL +#define MICROPY_PY_WEBREPL (0) +#endif + /*****************************************************************************/ /* Hooks for a port to add builtins */ diff --git a/py/mperrno.h b/py/mperrno.h index 1eb342bc36..f7dad4c542 100644 --- a/py/mperrno.h +++ b/py/mperrno.h @@ -26,8 +26,6 @@ #ifndef MICROPY_INCLUDED_PY_MPERRNO_H #define MICROPY_INCLUDED_PY_MPERRNO_H -#include "py/mpconfig.h" - #include "py/mpconfig.h" #include "py/obj.h" diff --git a/py/nlr.c b/py/nlr.c index 03d01577e1..1bfd9c19b0 100644 --- a/py/nlr.c +++ b/py/nlr.c @@ -28,7 +28,7 @@ #if !MICROPY_NLR_SETJMP // When not using setjmp, nlr_push_tail is called from inline asm so needs special care -#if MICROPY_NLR_X86 && MICROPY_NLR_OS_WINDOWS +#if defined(MICROPY_NLR_X86) && MICROPY_NLR_X86 && defined(MICROPY_NLR_OS_WINDOWS) && MICROPY_NLR_OS_WINDOWS // On these 32-bit platforms make sure nlr_push_tail doesn't have a leading underscore unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail"); #else diff --git a/py/nlr.h b/py/nlr.h index 90595a12d3..802f5f39a3 100644 --- a/py/nlr.h +++ b/py/nlr.h @@ -35,7 +35,8 @@ #include "py/mpconfig.h" // If MICROPY_NLR_SETJMP is not enabled then auto-detect the machine arch -#if !MICROPY_NLR_SETJMP +#if !defined(MICROPY_NLR_SETJMP) || !MICROPY_NLR_SETJMP +#define MICROPY_NLR_SETJMP (0) // A lot of nlr-related things need different treatment on Windows #if defined(_WIN32) || defined(__CYGWIN__) #define MICROPY_NLR_OS_WINDOWS 1 diff --git a/py/nlrx64.c b/py/nlrx64.c index a3a1cf341b..9b2b22c225 100644 --- a/py/nlrx64.c +++ b/py/nlrx64.c @@ -26,7 +26,7 @@ #include "py/mpstate.h" -#if MICROPY_NLR_X64 +#if defined(MICROPY_NLR_X64) && MICROPY_NLR_X64 #undef nlr_push diff --git a/py/nlrx86.c b/py/nlrx86.c index 59b97d8ee6..4900a4c0d2 100644 --- a/py/nlrx86.c +++ b/py/nlrx86.c @@ -26,14 +26,14 @@ #include "py/mpstate.h" -#if MICROPY_NLR_X86 +#if defined(MICROPY_NLR_X86) && MICROPY_NLR_X86 #undef nlr_push // For reference, x86 callee save regs are: // ebx, esi, edi, ebp, esp, eip -#if MICROPY_NLR_OS_WINDOWS +#if defined(MICROPY_NLR_OS_WINDOWS) && MICROPY_NLR_OS_WINDOWS unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail"); #else __attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr); diff --git a/py/nlrxtensa.c b/py/nlrxtensa.c index cd3dee364c..d66c7a9a7f 100644 --- a/py/nlrxtensa.c +++ b/py/nlrxtensa.c @@ -26,7 +26,7 @@ #include "py/mpstate.h" -#if MICROPY_NLR_XTENSA +#if defined(MICROPY_NLR_XTENSA) && MICROPY_NLR_XTENSA #undef nlr_push diff --git a/py/obj.h b/py/obj.h index 42c88ef67f..040c8630de 100644 --- a/py/obj.h +++ b/py/obj.h @@ -526,6 +526,8 @@ struct _mp_obj_type_t { extern const mp_obj_type_t mp_type_type; extern const mp_obj_type_t mp_type_object; extern const mp_obj_type_t mp_type_NoneType; +extern const mp_obj_type_t mp_type_bool; +extern const mp_obj_type_t mp_type_int; extern const mp_obj_type_t mp_type_str; extern const mp_obj_type_t mp_type_bytes; extern const mp_obj_type_t mp_type_bytearray; diff --git a/py/objtype.c b/py/objtype.c index dc9724e5b3..7244abd9e2 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -1283,7 +1283,8 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { attr_get_method[2] = self_in; attr_get_method[3] = MP_OBJ_FROM_PTR(mp_obj_get_type(self_in)); dest[0] = mp_call_method_n_kw(2, 0, attr_get_method); - } + } + #endif return; } diff --git a/py/parse.c b/py/parse.c index ab162710d7..f915f7598b 100644 --- a/py/parse.c +++ b/py/parse.c @@ -190,7 +190,7 @@ static const size_t FIRST_RULE_WITH_OFFSET_ABOVE_255 = #undef DEF_RULE_NC 0; -#if USE_RULE_NAME +#if defined(USE_RULE_NAME) && USE_RULE_NAME // Define an array of rule names corresponding to each rule STATIC const char *const rule_name_table[] = { #define DEF_RULE(rule, comp, kind, ...) #rule, @@ -403,7 +403,7 @@ void mp_parse_node_print(mp_parse_node_t pn, size_t indent) { #endif } else { size_t n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); - #if USE_RULE_NAME + #if defined(USE_RULE_NAME) && USE_RULE_NAME printf("%s(%u) (n=%u)\n", rule_name_table[MP_PARSE_NODE_STRUCT_KIND(pns)], (uint)MP_PARSE_NODE_STRUCT_KIND(pns), (uint)n); #else printf("rule(%u) (n=%u)\n", (uint)MP_PARSE_NODE_STRUCT_KIND(pns), (uint)n);