@@ -116,21 +116,28 @@ static mp_obj_t machine_sdcard_make_new(const mp_obj_type_t *type, size_t n_args
116116ARG_width ,
117117ARG_cd ,
118118ARG_wp ,
119+ ARG_cmd ,
120+ ARG_clk ,
121+ ARG_data_pins ,
119122ARG_spi_bus ,
120123ARG_cs ,
121124ARG_freq ,
122125 };
123126
124127static const mp_arg_t make_new_args []= {
125- {MP_QSTR_slot ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = 1 } },
126- {MP_QSTR_width ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = 1 } },
127- {MP_QSTR_cd ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = -1 } },
128- {MP_QSTR_wp ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = -1 } },
128+ {MP_QSTR_slot ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = 1 } },
129+ {MP_QSTR_width ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = 1 } },
130+ {MP_QSTR_cd ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = -1 } },
131+ {MP_QSTR_wp ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = -1 } },
132+ // Added so a user can set their own custom data pins
133+ {MP_QSTR_cmd ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = -1 } },
134+ {MP_QSTR_clk ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = -1 } },
135+ {MP_QSTR_data_pins ,MP_ARG_KW_ONLY |MP_ARG_OBJ , {.u_obj = mp_const_none } },
129136// These are only needed if using SPI mode
130- {MP_QSTR_spi_bus ,MP_ARG_KW_ONLY |MP_ARG_OBJ , {.u_obj = mp_const_none } },
131- {MP_QSTR_cs ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = -1 } },
137+ {MP_QSTR_spi_bus ,MP_ARG_KW_ONLY |MP_ARG_OBJ , {.u_obj = mp_const_none } },
138+ {MP_QSTR_cs ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = -1 } },
132139// freq is valid for both SPI and SDMMC interfaces
133- {MP_QSTR_freq ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = 20000000 } },
140+ {MP_QSTR_freq ,MP_ARG_KW_ONLY |MP_ARG_INT , {.u_int = 20000000 } },
134141 };
135142
136143mp_arg_val_t args [MP_ARRAY_SIZE (make_new_args )];
@@ -211,7 +218,34 @@ static mp_obj_t machine_sdcard_make_new(const mp_obj_type_t *type, size_t n_args
211218slot_config .gpio_cd = (int )args [ARG_cd ].u_int ;
212219slot_config .gpio_wp = (int )args [ARG_wp ].u_int ;
213220
214- int width = args [ARG_width ].u_int ;
221+ int clk = (int )args [ARG_clk ].u_int ;
222+ int cmd = (int )args [ARG_cmd ].u_int ;
223+ int width = (int )args [ARG_width ].u_int ;
224+
225+ if (clk != -1 )slot_config .clk = clk ;
226+ if (cmd != -1 )slot_config .cmd = cmd ;
227+
228+ if (args [ARG_data_pins ].u_obj != mp_const_none ) {
229+ mp_obj_tuple_t * t = MP_OBJ_TO_PTR (args [ARG_data_pins ].u_obj );
230+ if ((int )t -> len != width ) {
231+ mp_raise_ValueError (MP_ERROR_TEXT ("width does not match the number of data pins provided" ));
232+ }
233+
234+ slot_config .d0 = (int )mp_obj_get_int (t -> items [0 ]);
235+
236+ if (width >=4 ) {
237+ slot_config .d1 = (int )mp_obj_get_int (t -> items [1 ]);
238+ slot_config .d2 = (int )mp_obj_get_int (t -> items [2 ]);
239+ slot_config .d3 = (int )mp_obj_get_int (t -> items [3 ]);
240+ }
241+ if (width == 8 ) {
242+ slot_config .d4 = (int )mp_obj_get_int (t -> items [4 ]);
243+ slot_config .d5 = (int )mp_obj_get_int (t -> items [5 ]);
244+ slot_config .d6 = (int )mp_obj_get_int (t -> items [6 ]);
245+ slot_config .d7 = (int )mp_obj_get_int (t -> items [7 ]);
246+ }
247+ }
248+
215249if (width == 1 || width == 4 || (width == 8 && slot_num == 0 )) {
216250slot_config .width = width ;
217251 }else {