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 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; } }
/** * @brief return medium capacity and block size * @param lun : logical unit number * @param block_num : number of physical block * @param block_size : size of a physical block * @retval Status */ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_size) { /* #ifdef USE_STM3210C_EVAL SD_CardInfo SDCardInfo; SD_GetCardInfo(&SDCardInfo); #else if(SD_GetStatus() != 0 ) { return (-1); } #endif */ *block_size = storage_get_block_size(); //*block_num = SDCardInfo.CardCapacity / 512; *block_num = storage_get_block_count(); return (0); }
/** * @brief return medium capacity and block size * @param lun : logical unit number * @param block_num : number of physical block * @param block_size : size of a physical block * @retval Status */ int8_t FLASH_STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint32_t *block_size) { *block_size = storage_get_block_size(); *block_num = storage_get_block_count(); return 0; }