STATIC mp_obj_t pin_value(mp_uint_t n_args, const mp_obj_t *args) { pin_obj_t *self = args[0]; if (n_args == 1) { // get the value return MP_OBJ_NEW_SMALL_INT(pin_get_value(self)); } else { // set the pin value if (mp_obj_is_true(args[1])) { self->value = 1; MAP_GPIOPinWrite(self->port, self->bit, self->bit); } else { self->value = 0; MAP_GPIOPinWrite(self->port, self->bit, 0); } return mp_const_none; } }
/** * Возвращает текущее логическое значение на шине 1-wire. * @param ow Шина 1-wire */ ALWAYS_INLINE static uint8_t one_wire_get_value(one_wire_t* ow) { return pin_get_value(&ow->pin); }