diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-02-14 20:34:30 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-02-14 20:34:30 +0200 |
commit | 9e0478a902d311bd3f3b7c22468cf464723e0375 (patch) | |
tree | ede8b4d520ff087eab935be837133af9a1441095 | |
parent | 0ee1d0f407005f61776b1fb6bd827ac2ebc253ec (diff) | |
download | micropython-9e0478a902d311bd3f3b7c22468cf464723e0375.tar.gz micropython-9e0478a902d311bd3f3b7c22468cf464723e0375.zip |
stmhal/diskio: Add provision for default returns for ioctl INIT/SEC_SIZE.
If None was returned for such requests (which likely means that user simply
didn't handle them), it means successful init and default sector size of 512
bytes respectively. This makes only BP_IOCTL_SEC_COUNT a mandatory request,
and thus re-establishes parity with old interface, where only .count() is
mandatory().
-rw-r--r-- | stmhal/diskio.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/stmhal/diskio.c b/stmhal/diskio.c index fd40a6f8e7..03be24188e 100644 --- a/stmhal/diskio.c +++ b/stmhal/diskio.c @@ -63,7 +63,7 @@ DSTATUS disk_initialize ( vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_INIT); vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl); - if (MP_OBJ_SMALL_INT_VALUE(ret) != 0) { + if (ret != mp_const_none && MP_OBJ_SMALL_INT_VALUE(ret) != 0) { // error initialising return STA_NOINIT; } @@ -203,7 +203,12 @@ DRESULT disk_ioctl ( vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_SEC_SIZE); vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl); - *((WORD*)buff) = mp_obj_get_int(ret); + if (ret == mp_const_none) { + // Default sector size + *((WORD*)buff) = 512; + } else { + *((WORD*)buff) = mp_obj_get_int(ret); + } return RES_OK; } |