Browse Source

Merge pull request #4 from SummerGGift/add_pin_option

add pin driver option
朱天龙 (Armink) 8 years ago
parent
commit
44c10aa765
5 changed files with 12 additions and 2 deletions
  1. 2 1
      extmod/machine_signal.c
  2. 4 0
      port/machine_pin.c
  3. 2 1
      port/modmachine.c
  4. 2 0
      port/modpyb.c
  5. 2 0
      port/mpconfigport.h

+ 2 - 1
extmod/machine_signal.c

@@ -83,11 +83,12 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t
         if (invert && sig_value != NULL) {
             *sig_value = mp_obj_is_true(*sig_value) ? MP_OBJ_NEW_SMALL_INT(0) : MP_OBJ_NEW_SMALL_INT(1);
         }
-
+        #if MICROPY_PY_PIN
         // Here we pass NULL as a type, hoping that mp_pin_make_new()
         // will just ignore it as set a concrete type. If not, we'd need
         // to expose port's "default" pin type too.
         pin = MICROPY_PY_MACHINE_PIN_MAKE_NEW(NULL, n_args, n_kw, pin_args);
+        #endif
     }
     else
     #endif

+ 4 - 0
port/machine_pin.c

@@ -36,6 +36,8 @@
 #include "py/mphal.h"
 #include "modmachine.h"
 
+#if MICROPY_PY_PIN
+
 #define GPIO_MODE_IN                           ((uint32_t)0x00000000)   /*!< Input Floating Mode                   */
 #define GPIO_MODE_OUT_PP                       ((uint32_t)0x00000001)   /*!< Output Push Pull Mode                 */
 #define GPIO_MODE_OUT_OD                       ((uint32_t)0x00000011)   /*!< Output Open Drain Mode                */
@@ -240,3 +242,5 @@ const mp_obj_type_t machine_pin_type = {
     .protocol = &machine_pin_pin_p,
     .locals_dict = (mp_obj_t)&machine_pin_locals_dict,
 };
+
+#endif

+ 2 - 1
port/modmachine.c

@@ -183,8 +183,9 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR_disable_irq),         MP_ROM_PTR(&pyb_disable_irq_obj) },
     { MP_ROM_QSTR(MP_QSTR_enable_irq),          MP_ROM_PTR(&pyb_enable_irq_obj) },
 //    { MP_ROM_QSTR(MP_QSTR_time_pulse_us),       MP_ROM_PTR(&machine_time_pulse_us_obj) },
-
+#if MICROPY_PY_PIN
     { MP_ROM_QSTR(MP_QSTR_Pin),                 MP_ROM_PTR(&machine_pin_type) },
+#endif
     { MP_ROM_QSTR(MP_QSTR_Signal),              MP_ROM_PTR(&machine_signal_type) },
 //    { MP_ROM_QSTR(MP_QSTR_I2C),                 MP_ROM_PTR(&machine_i2c_type) },
 //    { MP_ROM_QSTR(MP_QSTR_SPI),                 MP_ROM_PTR(&machine_hard_spi_type) },

+ 2 - 0
port/modpyb.c

@@ -110,7 +110,9 @@ STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = {
 //    { MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&pyb_rtc_type) },
 //#endif
 //
+#if MICROPY_PY_PIN
     { MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&machine_pin_type) },
+#endif
 //    { MP_ROM_QSTR(MP_QSTR_ExtInt), MP_ROM_PTR(&extint_type) },
 //
 //#if MICROPY_HW_ENABLE_SERVO

+ 2 - 0
port/mpconfigport.h

@@ -118,6 +118,8 @@
 #define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_DOUBLE)
 #define MICROPY_READER_POSIX        (1)
 #define MICROPY_READER_VFS          (0)
+#define MICROPY_PY_PIN              (0)
+
 
 // extended modules
 #define MICROPY_PY_UCTYPES          (1)