/* Reads a number of bytes to a page in the internal Flash.  */
void _flash_read(struct _flash_device *const device, const uint32_t src_addr, uint8_t *buffer, uint32_t length)
/* Reads a number of bytes to a page in the internal Flash.  */
void _flash_read(struct _flash_device *const device, const uint32_t src_addr, uint8_t *buffer, uint32_t length)
{
	uint32_t nvm_address = src_addr / 2;
	uint32_t i;
	uint16_t data;
	while (!hri_nvmctrl_get_interrupt_READY_bit(device->hw)) {
	}
	hri_nvmctrl_clear_STATUS_reg(device->hw, NVMCTRL_STATUS_MASK);
	if (src_addr % 2) {
		data      = NVM_MEMORY[nvm_address++];
		buffer[0] = data >> 8;
		i         = 1;
	} else {
		i = 0;
	}
	while (i < length) {
		data      = NVM_MEMORY[nvm_address++];
		buffer[i] = (data & 0xFF);
		if (i < (length - 1)) {
			buffer[i + 1] = (data >> 8);
		}
		i += 2;
	}
}