diff --git a/cc3200/fatfs/src/drivers/sd_diskio.c b/cc3200/fatfs/src/drivers/sd_diskio.c index fbe73ebde7..57ff5ae620 100644 --- a/cc3200/fatfs/src/drivers/sd_diskio.c +++ b/cc3200/fatfs/src/drivers/sd_diskio.c @@ -360,6 +360,8 @@ DRESULT sd_disk_read (BYTE* pBuffer, DWORD ulSectorNumber, UINT SectorCount) { pBuffer += 4; } CardSendCmd(CMD_STOP_TRANS, 0); + // Wait for the command to complete + while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC)); Res = RES_OK; } } @@ -430,6 +432,8 @@ DRESULT sd_disk_write (const BYTE* pBuffer, DWORD ulSectorNumber, UINT SectorCou // Wait for transfer complete while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC)); CardSendCmd(CMD_STOP_TRANS, 0); + // Wait for the command to complete + while (!(MAP_SDHostIntStatus(SDHOST_BASE) & SDHOST_INT_TC)); Res = RES_OK; } } diff --git a/cc3200/mods/pybsd.c b/cc3200/mods/pybsd.c index 6d326ded51..c54dfc7051 100644 --- a/cc3200/mods/pybsd.c +++ b/cc3200/mods/pybsd.c @@ -131,11 +131,17 @@ STATIC mp_obj_t pybsd_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_ pin_verify_af (pybsd_obj.af_cmd); // configure the sdhost pins + // TODO: all pin configs must go through pin_config() MAP_PinTypeSDHost(pybsd_obj.pin_d0->pin_num, pybsd_obj.af_d0); MAP_PinTypeSDHost(pybsd_obj.pin_clk->pin_num, pybsd_obj.af_clk); MAP_PinDirModeSet(pybsd_obj.pin_clk->pin_num, PIN_DIR_MODE_OUT); MAP_PinTypeSDHost(pybsd_obj.pin_cmd->pin_num, pybsd_obj.af_cmd); + // enable pull-ups on data and cmd + // TODO: all pin configs must go through pin_config() + MAP_PinConfigSet(pybsd_obj.pin_d0->pin_num, PIN_STRENGTH_4MA, PIN_TYPE_STD_PU); + MAP_PinConfigSet(pybsd_obj.pin_cmd->pin_num, PIN_STRENGTH_4MA, PIN_TYPE_STD_PU); + // card detect pin was provided if (n_args == 7) { pybsd_obj.pin_sd_detect = (pin_obj_t *)pin_find(args[6]); @@ -152,6 +158,8 @@ STATIC mp_obj_t pybsd_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_ nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, mpexception_num_type_invalid_arguments)); } + // TODO: register with the sleep module!! + pybsd_obj.base.type = &pyb_sd_type; return &pybsd_obj; }