modadvanced: conditionally compile hbridge
This is needed for now to ensure that the debug port will build, which currently does not have the hbridge code enabled.
@@ -29,7 +29,9 @@ class IODevice():
typedef struct _advanced_IODevice_obj_t {
mp_obj_base_t base;
pbio_iodev_t *iodev;
+#if PBDRV_CONFIG_HBRIDGE
pbio_hbridge_t *hbridge;
+#endif
} advanced_IODevice_obj_t;
/*
@@ -45,11 +47,11 @@ STATIC mp_obj_t advanced_IODevice_make_new(const mp_obj_type_t *type, size_t n_a
pbio_port_t port = mp_obj_get_int(args[0]);
pb_assert(pbdrv_ioport_get_iodev(port, &self->iodev));
+#if PBDRV_CONFIG_HBRIDGE
pbio_error_t err;
- pb_thread_enter();
err = pbio_hbridge_get(port, &self->hbridge, PBIO_DIRECTION_COUNTERCLOCKWISE, 0, 10000);
- pb_thread_exit();
pb_assert(err);
+#endif
return MP_OBJ_FROM_PTR(self);
}
@@ -102,6 +104,7 @@ STATIC mp_obj_t advanced_IODevice_values(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(advanced_IODevice_values_obj, 1, 2, advanced_IODevice_values);
+#if PBDRV_CONFIG_HBRIDGE
STATIC mp_obj_t advanced_IODevice_supply_on(mp_obj_t self_in) {
advanced_IODevice_obj_t *self = MP_OBJ_TO_PTR(self_in);
pbio_error_t err;
@@ -134,7 +137,7 @@ STATIC mp_obj_t advanced_IODevice_supply_off(mp_obj_t self_in) {
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(advanced_IODevice_supply_off_obj, advanced_IODevice_supply_off);
-
+#endif // PBDRV_CONFIG_HBRIDGE
/*
IODevice class tables
@@ -143,8 +146,10 @@ STATIC const mp_rom_map_elem_t advanced_IODevice_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_type_id), MP_ROM_PTR(&advanced_IODevice_type_id_obj) },
{ MP_ROM_QSTR(MP_QSTR_values), MP_ROM_PTR(&advanced_IODevice_values_obj) },
{ MP_ROM_QSTR(MP_QSTR_mode), MP_ROM_PTR(&advanced_IODevice_mode_obj) },
+#if PBDRV_CONFIG_HBRIDGE
{ MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&advanced_IODevice_supply_on_obj) },
{ MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&advanced_IODevice_supply_off_obj) },
+#endif
};
STATIC MP_DEFINE_CONST_DICT(advanced_IODevice_locals_dict, advanced_IODevice_locals_dict_table);
