/* Function for fetching length of file to be programmed. 
Master initially transmits 4 bytes - which is the length of the the data to be programmed to the device.  */
static uint32_t get_length(void)
/* Function for fetching length of file to be programmed. 
Master initially transmits 4 bytes - which is the length of the the data to be programmed to the device.  */
static uint32_t get_length(void)
{
	uint8_t read_buffer[4];
	uint32_t len = 0;
	while (spi_read_buffer_wait(&slave, read_buffer, 4, dummy) != STATUS_OK);
	MSB0W(len) = read_buffer[0];
	MSB1W(len) = read_buffer[1];
	MSB2W(len) = read_buffer[2];
	MSB3W(len) = read_buffer[3];
	return len;
}