/** * @brief Read data from the medium * @param lun : logical unit number * @param buf : Pointer to the buffer to save data * @param blk_addr : address of 1st block to be read * @param blk_len : nmber of blocks to be read * @retval Status */ int8_t FLASH_STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) { storage_read_blocks(buf, blk_addr, blk_len); /* for (int i = 0; i < blk_len; i++) { if (!storage_read_block(buf + i * FLASH_BLOCK_SIZE, blk_addr + i)) { return -1; } } */ return 0; }
STATIC mp_obj_t pyb_flash_readblocks(mp_obj_t self, mp_obj_t block_num, mp_obj_t buf) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_WRITE); mp_uint_t ret = storage_read_blocks(bufinfo.buf, mp_obj_get_int(block_num), bufinfo.len / FLASH_BLOCK_SIZE); return MP_OBJ_NEW_SMALL_INT(ret); }