STATIC mp_obj_t pyb_sd_init_helper (pybsd_obj_t *self, const mp_arg_val_t *args) { // assign the pins mp_obj_t pins_o = args[0].u_obj; if (pins_o != mp_const_none) { mp_obj_t *pins; if (pins_o == MP_OBJ_NULL) { // use the default pins pins = (mp_obj_t *)pyb_sd_def_pin; } else { mp_obj_get_array_fixed_n(pins_o, MP_ARRAY_SIZE(pyb_sd_def_pin), &pins); } pin_assign_pins_af (pins, MP_ARRAY_SIZE(pyb_sd_def_pin), PIN_TYPE_STD_PU, PIN_FN_SD, 0); // save the pins clock self->pin_clk = pin_find(pins[0]); } pyb_sd_hw_init (self); if (sd_disk_init() != 0) { mp_raise_OSError(MP_EIO); } // register it with the sleep module pyb_sleep_add ((const mp_obj_t)self, (WakeUpCB_t)pyb_sd_hw_init); return mp_const_none; }
void pin_config (pin_obj_t *self, int af, uint mode, uint pull, int value, uint strength) { self->mode = mode, self->pull = pull, self->strength = strength; // if af is -1, then we want to keep it as it is if (af != -1) { self->af = af; } // if value is -1, then we want to keep it as it is if (value != -1) { self->value = value; } // mark the pin as used self->used = true; pin_obj_configure ((const pin_obj_t *)self); // register it with the sleep module pyb_sleep_add ((const mp_obj_t)self, (WakeUpCB_t)pin_obj_configure); }