#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"
#include "unistd.h"
#include "io.h"
#include "system.h"




#define tft_base (SDRAM_FB_BASE + SDRAM_FB_BASE / 2) // Where we want our frame buffers
#define  WIDTH 800
#define  HEIGHT 480

volatile uint8_t *fb = tft_base | 0x80000000;


void fb_init(uint8_t *framebuffer, int width, int height, int color_depth) {
	IOWR(MASTER_RD_CTRL_BASE, 0, 0);	//رʾ
	IOWR(MASTER_RD_CTRL_BASE, 1, framebuffer);	//ַָ
	IOWR(MASTER_RD_CTRL_BASE, 2, width*height*color_depth/8);	//ָС
	IOWR(MASTER_RD_CTRL_BASE, 0, 0x2);	//ʾ
}

void display_device_init() {
	fb_init(fb, WIDTH, HEIGHT, 8);
	memset(fb, 3, 800*480);
}

int main()
{
	display_device_init();

  return 0;
}
