summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-02-10 23:36:19 +0000
committerDamien George <damien.p.george@gmail.com>2016-02-10 23:40:35 +0000
commite372e83b3042cb48fbe5706522d92f7aa5404ae6 (patch)
tree90e7789e6602681fc1fb3026b9b0f956f24ed64e
parentb33a7705966a743c5e4c0c3c3bb83e6d97b5e84d (diff)
downloadmicropython-e372e83b3042cb48fbe5706522d92f7aa5404ae6.tar.gz
micropython-e372e83b3042cb48fbe5706522d92f7aa5404ae6.zip
extmod/fsusermount: Move BP_IOCTL_xxx constants to fsusermount.h.
-rw-r--r--extmod/fsusermount.h7
-rw-r--r--stmhal/diskio.c7
-rw-r--r--stmhal/sdcard.c10
-rw-r--r--stmhal/storage.c10
4 files changed, 17 insertions, 17 deletions
diff --git a/extmod/fsusermount.h b/extmod/fsusermount.h
index 3dcd035918..9e0d74e793 100644
--- a/extmod/fsusermount.h
+++ b/extmod/fsusermount.h
@@ -29,6 +29,13 @@
#define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount
#define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl
+// constants for block protocol ioctl
+#define BP_IOCTL_INIT (1)
+#define BP_IOCTL_DEINIT (2)
+#define BP_IOCTL_SYNC (3)
+#define BP_IOCTL_SEC_COUNT (4)
+#define BP_IOCTL_SEC_SIZE (5)
+
typedef struct _fs_user_mount_t {
const char *str;
uint16_t len; // length of str
diff --git a/stmhal/diskio.c b/stmhal/diskio.c
index 998729a70d..f336b73771 100644
--- a/stmhal/diskio.c
+++ b/stmhal/diskio.c
@@ -37,13 +37,6 @@
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
#include "extmod/fsusermount.h"
-// constants for block protocol ioctl
-#define BP_IOCTL_INIT (1)
-//#define BP_IOCTL_DEINIT (2) // unused
-#define BP_IOCTL_SYNC (3)
-#define BP_IOCTL_SEC_COUNT (4)
-#define BP_IOCTL_SEC_SIZE (5)
-
STATIC fs_user_mount_t *disk_get_device(uint id) {
if (id < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
return MP_STATE_PORT(fs_user_mount)[id];
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index ae96de953f..59fe3fac82 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -377,24 +377,24 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_sdcard_writeblocks_obj, pyb_sdcard_writeblo
STATIC mp_obj_t pyb_sdcard_ioctl(mp_obj_t self, mp_obj_t cmd_in, mp_obj_t arg_in) {
mp_int_t cmd = mp_obj_get_int(cmd_in);
switch (cmd) {
- case 1: // INIT
+ case BP_IOCTL_INIT:
if (!sdcard_power_on()) {
return MP_OBJ_NEW_SMALL_INT(-1); // error
}
return MP_OBJ_NEW_SMALL_INT(0); // success
- case 2: // DEINIT
+ case BP_IOCTL_DEINIT:
sdcard_power_off();
return MP_OBJ_NEW_SMALL_INT(0); // success
- case 3: // SYNC
+ case BP_IOCTL_SYNC:
// nothing to do
return MP_OBJ_NEW_SMALL_INT(0); // success
- case 4: // SEC_COUNT
+ case BP_IOCTL_SEC_COUNT:
return MP_OBJ_NEW_SMALL_INT(0); // TODO
- case 5: // SEC_SIZE
+ case BP_IOCTL_SEC_SIZE:
return MP_OBJ_NEW_SMALL_INT(SDCARD_BLOCK_SIZE);
default: // unknown command
diff --git a/stmhal/storage.c b/stmhal/storage.c
index f6075c43c4..93eba60f54 100644
--- a/stmhal/storage.c
+++ b/stmhal/storage.c
@@ -363,11 +363,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_flash_writeblocks_obj, pyb_flash_writeblock
STATIC mp_obj_t pyb_flash_ioctl(mp_obj_t self, mp_obj_t cmd_in, mp_obj_t arg_in) {
mp_int_t cmd = mp_obj_get_int(cmd_in);
switch (cmd) {
- case 1: storage_init(); return MP_OBJ_NEW_SMALL_INT(0); // INIT
- case 2: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // DEINIT; TODO properly
- case 3: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // SYNC
- case 4: return MP_OBJ_NEW_SMALL_INT(storage_get_block_count()); // SEC_COUNT
- case 5: return MP_OBJ_NEW_SMALL_INT(storage_get_block_size()); // SEC_SIZE
+ case BP_IOCTL_INIT: storage_init(); return MP_OBJ_NEW_SMALL_INT(0);
+ case BP_IOCTL_DEINIT: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // TODO properly
+ case BP_IOCTL_SYNC: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0);
+ case BP_IOCTL_SEC_COUNT: return MP_OBJ_NEW_SMALL_INT(storage_get_block_count());
+ case BP_IOCTL_SEC_SIZE: return MP_OBJ_NEW_SMALL_INT(storage_get_block_size());
default: return mp_const_none;
}
}