/* Reads a number of bytes to a page in the internal Flash.  */
int32_t flash_read(struct flash_descriptor *flash, uint32_t src_addr, uint8_t *buffer, uint32_t length)
/* Reads a number of bytes to a page in the internal Flash.  */
int32_t flash_read(struct flash_descriptor *flash, uint32_t src_addr, uint8_t *buffer, uint32_t length)
{
	ASSERT(flash && buffer && length);
	uint32_t page_size   = _flash_get_page_size(&flash->dev);
	uint32_t total_pages = _flash_get_total_pages(&flash->dev);
	if ((src_addr > page_size * total_pages) || (src_addr + length > page_size * total_pages)) {
		return ERR_BAD_ADDRESS;
	}
	_flash_read(&flash->dev, src_addr, buffer, length);
	return ERR_NONE;
}