#include <stdio.h>
#include <stdint.h>

#define H_SIZE 2432
#define V_SIZE 2048
#define BPP 3

const int8_t *file_name = "..\\yuv.data";

#pragma DATA_SECTION(yuv_data, ".image_data")
uint8_t yuv_data[H_SIZE*V_SIZE*BPP];

int16_t main(void)
{
	uint32_t return_code = 0;
	uint32_t file_size = 0;
	FILE *data_file;

	/* Open the data file */
	data_file = fopen(file_name, "r");
	if (data_file == NULL)
	{
		printf("Error opening %s\n", file_name);
		return(-1);
	}

	/* Get the size of the output file */
	fseek(data_file, 0, SEEK_END);
	file_size = ftell(data_file);
	rewind(data_file);

	/* Read the data from the file */
	return_code = fread(yuv_data, sizeof(uint8_t), file_size, data_file);
	if (return_code < (file_size / sizeof(uint8_t)))
	{
		printf("Error in reading file: %d bytes were written to address 0x%x\n", return_code, yuv_data);
		fclose(data_file);
		return(-1);
	}

	/* Putting a breakpoint here to inspect the memory... */
	asm("  BKPT #0xFF");

	/* Close the file */
	fclose(data_file);
	
	return 0;
}
