Ejemplo n.º 1
0
int main(void)
{
	int i;
	
	uart_init(); /* ³õʼ»¯UART0 */
	wy_printf("LCD initialize ...\n");
	lcd_init();
	
	while (1)
	{
		wy_printf("display red\n");
		lcd_clear_screen(0xff0000);
		for(i=50;i>0;i--)
			delay();
		wy_printf("display green\n");
		lcd_clear_screen(0x00ff00);
		for(i=50;i>0;i--)
			delay();
		wy_printf("display blue\n");
		lcd_clear_screen(0x0000ff);
		for(i=50;i>0;i--)
			delay();
		nand_read((unsigned char *)0x3fc00000, 0xC00000, 0x300000);
		wy_printf("display girl\n");
		lcd_draw_bmp(0x3fc00000);
		for(i=150;i>0;i--)
			delay();
	}

	return 0;
}
Ejemplo n.º 2
0
// before download this bin to 0x21000000, you should first "loadb 0x22000000" to load test.bmp file to 0x22000000
int c_entry(void)
{
    char * p = (char *)BMP_ADDR;
    char red, blue, green;
    int color;
    int i, j;

    lcd_init();

    lcd_clear_screen(0x000000);	// black

    // read bmp file
    // bmp file header is 54 bytes
    p += 54;

    for (i = 0; i < 272; i++)
        for (j = 0; j < 480; j++)
        {
            blue = *p++;
            green = *p++;
            red = *p++;

            color = red << 16 | green << 8 | blue << 0;

            lcd_draw_pixel(271-i, j, color);
        }

    while (1);

    return 0;
}
static void lcd_handle_escape(alt_LCD_16207_dev * dev, char c)
{
  int parm1 = 0, parm2 = 0;

  if (dev->escape[0] == '[')
  {
    char * ptr = dev->escape+1;
    while (isdigit(*ptr))
      parm1 = (parm1 * 10) + (*ptr++ - '0');

    if (*ptr == ';')
    {
      ptr++;
      while (isdigit(*ptr))
        parm2 = (parm2 * 10) + (*ptr++ - '0');
    }
  }
  else
    parm1 = -1;

  switch (c)
  {
  case 'H': /* ESC '[' <y> ';' <x> 'H'  : Move cursor to location */
  case 'f': /* Same as above */
    if (parm2 > 0)
      dev->x = parm2 - 1;
    if (parm1 > 0)
    {
      dev->y = parm1 - 1;
      if (dev->y > ALT_LCD_HEIGHT * 2)
        dev->y = ALT_LCD_HEIGHT * 2;
      while (dev->y > ALT_LCD_HEIGHT)
        lcd_scroll_up(dev);
    }
    break;

  case 'J':
    /*   ESC J      is clear to beginning of line    [unimplemented]
     *   ESC [ 0 J  is clear to bottom of screen     [unimplemented]
     *   ESC [ 1 J  is clear to beginning of screen  [unimplemented]
     *   ESC [ 2 J  is clear screen
     */
    if (parm1 == 2)
      lcd_clear_screen(dev);
    break;

  case 'K':
    /*   ESC K      is clear to end of line
     *   ESC [ 0 K  is clear to end of line
     *   ESC [ 1 K  is clear to beginning of line    [unimplemented]
     *   ESC [ 2 K  is clear line                    [unimplemented]
     */
    if (parm1 < 1)
    {
      if (dev->x < ALT_LCD_VIRTUAL_WIDTH)
        memset(dev->line[dev->y].data + dev->x, ' ', ALT_LCD_VIRTUAL_WIDTH - dev->x);
    }
    break;
  }
}
/*
 * lcd_16207_init is called at boot time to initialise the LCD driver
 */
void alt_lcd_16207_init(alt_LCD_16207_dev * dev)
{
  unsigned int base = dev->base;

  /* Mark the device as functional */
  dev->broken = 0;

  ALT_SEM_CREATE (&dev->write_lock, 1);

  /* TODO: check that usleep can be called in an initialisation routine */

  /* The initialisation sequence below is copied from the datasheet for
   * the 16207 LCD display.  The first commands need to be timed because
   * the BUSY bit in the status register doesn't work until the display
   * has been reset three times.
   */

  /* Wait for 15 ms then reset */
  usleep(15000);
  IOWR_ALTERA_AVALON_LCD_16207_COMMAND(base, LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT);

  /* Wait for another 4.1ms and reset again */
  usleep(4100);
  IOWR_ALTERA_AVALON_LCD_16207_COMMAND(base, LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT);

  /* Wait a further 1 ms and reset a third time */
  usleep(1000);
  IOWR_ALTERA_AVALON_LCD_16207_COMMAND(base, LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT);

  /* Setup interface parameters: 8 bit bus, 2 rows, 5x7 font */
  lcd_write_command(dev, LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT | LCD_CMD_TWO_LINE);

  /* Turn display off */
  lcd_write_command(dev, LCD_CMD_ONOFF);

  /* Clear display */
  lcd_clear_screen(dev);

  /* Set mode: increment after writing, don't shift display */
  lcd_write_command(dev, LCD_CMD_MODES | LCD_CMD_MODE_INC);

  /* Turn display on */
  lcd_write_command(dev, LCD_CMD_ONOFF | LCD_CMD_ENABLE_DISP);

  dev->esccount = -1;
  memset(dev->escape, 0, sizeof(dev->escape));

  dev->scrollpos = 0;
  dev->scrollmax = 0;
  dev->active = 0;

  dev->period = alt_ticks_per_second() / 10; /* Call every 100ms */

  alt_alarm_start(&dev->alarm, dev->period, &alt_lcd_16207_timeout, dev);

  /* make the device available to the system */
  alt_dev_reg(&dev->dev);
}
Ejemplo n.º 5
0
int mymain(void)
{	
	char * p = (char *)BMP_ADDR;
	char red, blue, green;
	int color;
	int i, j;
	
	puts("vga init\n");
	vga_init();

	puts("lcd init\n");
	lcd_init();
	
	lcd_clear_screen(0x000000);	// black	

	puts("lcd draw line\n");
	lcd_draw_hline(100, 100, 640-100, 0xff0000);	// red
	lcd_draw_hline(200, 100, 640-100, 0x00ff00);	// green
	lcd_draw_hline(300, 100, 640-100, 0x0000ff);	// blue
	lcd_draw_hline(400, 100, 640-100, 0xffffff);	// white

	lcd_draw_vline(640/2, 50, 480-50, 0xffffff);	// white
	
	#define POS	50
	#define HALF	20
	lcd_draw_cross(POS, POS, HALF);
	lcd_draw_cross(POS, 640-POS, HALF);
	
	lcd_draw_cross(480-POS, POS, HALF);
	lcd_draw_cross(480-POS, 640-POS, HALF);
	
	//while (1);
	
	// show BMP file
		// read bmp file
	// bmp file header is 54 bytes
	p += 54;
	
	for (i = 0; i < 272; i++)
		for (j = 0; j < 480; j++)
		{
			blue = *p++;
			green = *p++;
			red = *p++;
		
			color = red << 16 | green << 8 | blue << 0;
			
			lcd_draw_pixel(272-i, j, color);
		}
	
	while (1);
	
	return 0;
}
Ejemplo n.º 6
0
int main(void)
{
	int c = 0;

	init_uart();
	
	// 初始化LCD控制器
	lcd_init();

	// 打印菜单
	while(1)
	{
		printf("\r\n###############lcd test##############\r\n");
		printf("[1] lcd_clear_screen\r\n");
		printf("[2] lcd_draw_cross\r\n");
		printf("[3] lcd_draw_hline\r\n");
		printf("[4] lcd_draw_vline\r\n");
		printf("[5] lcd_draw_circle\r\n");
		printf("Enter your choice:");
		c = getc();
		printf("%c\r\n",c);
		switch(c)
		{
		case '1':
			// 清屏
			lcd_clear_screen(0xFFFFFF);
			break;
		case '2':
			// 划十字
			lcd_draw_cross(50, 50, 20, 0x000000);
			break;
		case '3':
			// 划横线
			lcd_draw_hline(HEIGHT/2, 100, WIDTHEIGHT-100, 0xff0000);
			break;
		case '4':
			// 划竖线
			lcd_draw_vline(WIDTHEIGHT/2, 50, HEIGHT-50, 0xff0000);
			break;
		case '5':
			// 划圆
			lcd_draw_circle();
			break;
		}
	}
	return 0;
}
Ejemplo n.º 7
0
int main(void)
{

	//DDRA=0XFF;
	//PORTA=0X00;

	//DDRE &= ~(1<<PE4);
	//PORTE &= ~(1<<PE4);	


	DDRD=0XFF;
	
	//void SPI0_Init(void)
	DDRB=0xff;			// make port as a output
	PORTB=0X00;		//disable pull-ups and make it tri state

	SPCR=0x50;          //SPI , SPI FOSC/16
	SPSR=0x00;			//setup SPI

	//  reser LCD
	PORTB &= ~(1<<PB1);		//PB6 -> PB1
	_delay_us(5);
	PORTB |= (1<<PB1);
	_delay_us(5);

	
	LCD_WRITE_COMMAND( 0x000, 0x0001 ); /* oschilliation start */
	_delay_us( 10 );
	/* Power settings */  	
	LCD_WRITE_COMMAND( 0x100, 0x0000 ); /*power supply setup*/	
	LCD_WRITE_COMMAND( 0x101, 0x0000 ); 
	LCD_WRITE_COMMAND( 0x102, 0x3110 ); 
	LCD_WRITE_COMMAND( 0x103, 0xe200 ); 
	LCD_WRITE_COMMAND( 0x110, 0x009d ); 
	LCD_WRITE_COMMAND( 0x111, 0x0022 ); 
	LCD_WRITE_COMMAND( 0x100, 0x0120 ); 
	_delay_us( 20 );

	LCD_WRITE_COMMAND( 0x100, 0x3120 );
	_delay_us( 80 );
	/* Display control */   
	LCD_WRITE_COMMAND( 0x001, 0x0100 );
	LCD_WRITE_COMMAND( 0x002, 0x0000 );
	LCD_WRITE_COMMAND( 0x003, 0x1230 );
	LCD_WRITE_COMMAND( 0x006, 0x0000 );
	LCD_WRITE_COMMAND( 0x007, 0x0101 );
	LCD_WRITE_COMMAND( 0x008, 0x0808 );
	LCD_WRITE_COMMAND( 0x009, 0x0000 );
	LCD_WRITE_COMMAND( 0x00b, 0x0000 );
	LCD_WRITE_COMMAND( 0x00c, 0x0000 );
	LCD_WRITE_COMMAND( 0x00d, 0x0018 );
	/* LTPS control settings */   
	LCD_WRITE_COMMAND( 0x012, 0x0000 );
	LCD_WRITE_COMMAND( 0x013, 0x0000 );
	LCD_WRITE_COMMAND( 0x018, 0x0000 );
	LCD_WRITE_COMMAND( 0x019, 0x0000 );

	LCD_WRITE_COMMAND( 0x203, 0x0000 );
	LCD_WRITE_COMMAND( 0x204, 0x0000 );

	LCD_WRITE_COMMAND( 0x210, 0x0000 );
	LCD_WRITE_COMMAND( 0x211, 0x00ef );
	LCD_WRITE_COMMAND( 0x212, 0x0000 );
	LCD_WRITE_COMMAND( 0x213, 0x013f );
	LCD_WRITE_COMMAND( 0x214, 0x0000 );
	LCD_WRITE_COMMAND( 0x215, 0x0000 );
	LCD_WRITE_COMMAND( 0x216, 0x0000 );
	LCD_WRITE_COMMAND( 0x217, 0x0000 );

	// Gray scale settings
	LCD_WRITE_COMMAND( 0x300, 0x5343);
	LCD_WRITE_COMMAND( 0x301, 0x1021);
	LCD_WRITE_COMMAND( 0x302, 0x0003);
	LCD_WRITE_COMMAND( 0x303, 0x0011);
	LCD_WRITE_COMMAND( 0x304, 0x050a);
	LCD_WRITE_COMMAND( 0x305, 0x4342);
	LCD_WRITE_COMMAND( 0x306, 0x1100);
	LCD_WRITE_COMMAND( 0x307, 0x0003);
	LCD_WRITE_COMMAND( 0x308, 0x1201);
	LCD_WRITE_COMMAND( 0x309, 0x050a);

	/* RAM access settings */ 
	LCD_WRITE_COMMAND( 0x400, 0x4027 );
	LCD_WRITE_COMMAND( 0x401, 0x0000 );
	LCD_WRITE_COMMAND( 0x402, 0x0000 );	/* First screen drive position (1) */   	
	LCD_WRITE_COMMAND( 0x403, 0x013f );	/* First screen drive position (2) */   	
	LCD_WRITE_COMMAND( 0x404, 0x0000 );

	LCD_WRITE_COMMAND( 0x200, 0x0000 );
	LCD_WRITE_COMMAND( 0x201, 0x0000 );
	
	LCD_WRITE_COMMAND( 0x100, 0x7120 );
	LCD_WRITE_COMMAND( 0x007, 0x0103 );
	_delay_us( 10 );
	LCD_WRITE_COMMAND( 0x007, 0x0113 );


	_delay_us(20);
	
	//while(1)
	//{
		lcd_clear_screen(WHITE);
		lcd_display_string( "Hello world!!!    ", BLACK, GREEN, 0, 0 );
		lcd_display_string( "I am Happy.^o^    ", BLACK, ORANGE, 0, 1 );
		lcd_display_string( "CPU:ATMAGE328A-AU          ", BLACK, PINK, 0, 2 );
		

	//}

	
		
         // wait for a second
	
	/*
//	_delay_ms(5000);
	while(1)
	{
		read_res=Read_Continue();
		lcd_draw_bigdot(BLACK,(touch_dot.x-20),(touch_dot.y-2));
//		for(i=0;i<100;i++)
//		{
//			lcd_draw_bigdot(BLACK,50,i);
//		}
//		lcd_draw_line(BLACK,0,0,20,20);
	
	}
	*/
}
Ejemplo n.º 8
0
int mymain(void)
{	
	int i;
	
	for (i = 0; i < 0x100000; i++)
	{
		*(char *)(0x30000000 + i) = 0;
	}
#if 0
//*(volatile unsigned int *)0x48000000 = 0x2211d120;
//*(volatile unsigned int *)0x48000004 = 0x00000700;
//*(volatile unsigned int *)0x48000008 = 0x00000700;
//*(volatile unsigned int *)0x4800000c = 0x00000700;
//*(volatile unsigned int *)0x48000010 = 0x00001f4c;
//*(volatile unsigned int *)0x48000014 = 0x00000700;
//*(volatile unsigned int *)0x48000018 = 0x00000700;
//*(volatile unsigned int *)0x4800001c = 0x00018005;
//*(volatile unsigned int *)0x48000020 = 0x00018005;
//*(volatile unsigned int *)0x48000024 = 0x008e0459;
//*(volatile unsigned int *)0x48000028 = 0x00000032;
*(volatile unsigned int *)0x4800002c = 0x00000030;
//*(volatile unsigned int *)0x48000030 = 0x00000030;
;
#endif

#if 0
*(volatile unsigned int *)0x4c000000 = 0x00ffffff;
*(volatile unsigned int *)0x4c000004 = 0x00044011;
*(volatile unsigned int *)0x4c000008 = 0x00038042;
*(volatile unsigned int *)0x4c00000c = 0x00fffff0;
*(volatile unsigned int *)0x4c000010 = 0x00000004;
*(volatile unsigned int *)0x4c000014 = 0x00000007;
*(volatile unsigned int *)0x4c000018 = 0x00000000;
*(volatile unsigned int *)0x4c00001c = 0x00000000;
*(volatile unsigned int *)0x4c000020 = 0x00ffffff;
*(volatile unsigned int *)0x4c000024 = 0x00044011;
;
#endif

#if 0
*(volatile unsigned int *)0x4d000000 = 0x00000000;
*(volatile unsigned int *)0x4d000004 = 0x00000000;
*(volatile unsigned int *)0x4d000008 = 0x00000000;
*(volatile unsigned int *)0x4d00000c = 0x00000000;
*(volatile unsigned int *)0x4d000010 = 0x00000000;
*(volatile unsigned int *)0x4d000014 = 0x00000000;
*(volatile unsigned int *)0x4d000018 = 0x00000000;
*(volatile unsigned int *)0x4d00001c = 0x00000000;
*(volatile unsigned int *)0x4d000020 = 0x00000000;
*(volatile unsigned int *)0x4d000024 = 0x00000000;
*(volatile unsigned int *)0x4d000028 = 0x00000000;
*(volatile unsigned int *)0x4d00002c = 0x0000a5a5;
*(volatile unsigned int *)0x4d000030 = 0x0ba5da65;
*(volatile unsigned int *)0x4d000034 = 0x000a5a5f;
*(volatile unsigned int *)0x4d000038 = 0x00000d6b;
*(volatile unsigned int *)0x4d00003c = 0x0eb7b5ed;
*(volatile unsigned int *)0x4d000040 = 0x00007dbe;
*(volatile unsigned int *)0x4d000044 = 0x0007ebdf;
*(volatile unsigned int *)0x4d000048 = 0x07fdfbfe;
*(volatile unsigned int *)0x4d00004c = 0x00000000;
*(volatile unsigned int *)0x4d000050 = 0x00000000;
*(volatile unsigned int *)0x4d000054 = 0x00000000;
*(volatile unsigned int *)0x4d000058 = 0x00000001;
*(volatile unsigned int *)0x4d00005c = 0x00000003;
*(volatile unsigned int *)0x4d000060 = 0x00000ce6;
*(volatile unsigned int *)0x4d000064 = 0x00000000;
*(volatile unsigned int *)0x4d000068 = 0x00000000;
*(volatile unsigned int *)0x4d00006c = 0x00000000;
*(volatile unsigned int *)0x4d000070 = 0x00000000;
*(volatile unsigned int *)0x4d000074 = 0x00000000;
;
#endif

#if 0
	*(volatile unsigned int *)0x56000000 = 0x007fffff;
	*(volatile unsigned int *)0x56000004 = 0x00000000;
	*(volatile unsigned int *)0x56000008 = 0x00000000;
	*(volatile unsigned int *)0x5600000c = 0x00000000;
	*(volatile unsigned int *)0x56000010 = 0x002a9655;
	*(volatile unsigned int *)0x56000014 = 0x0000028e;
	*(volatile unsigned int *)0x56000018 = 0x000007ff;
	*(volatile unsigned int *)0x5600001c = 0x00000000;
	*(volatile unsigned int *)0x56000020 = 0xaaaaaaaa;
	*(volatile unsigned int *)0x56000024 = 0x00000000;
	*(volatile unsigned int *)0x56000028 = 0x0000ffff;
	*(volatile unsigned int *)0x5600002c = 0x00000000;
	*(volatile unsigned int *)0x56000030 = 0xaaaaaaaa;
	*(volatile unsigned int *)0x56000034 = 0x00000000;
	*(volatile unsigned int *)0x56000038 = 0x0000ffff;
	*(volatile unsigned int *)0x5600003c = 0x00000000;
	*(volatile unsigned int *)0x56000040 = 0xaaaaaaaa;
	*(volatile unsigned int *)0x56000044 = 0x0000cfe5;
	*(volatile unsigned int *)0x56000048 = 0x0000ffff;
	*(volatile unsigned int *)0x5600004c = 0x00000000;
	*(volatile unsigned int *)0x56000050 = 0x000055aa;
	*(volatile unsigned int *)0x56000054 = 0x00000005;
	*(volatile unsigned int *)0x56000058 = 0x000000ff;
	*(volatile unsigned int *)0x5600005c = 0x00000000;
	*(volatile unsigned int *)0x56000060 = 0xfd95ffba;
	*(volatile unsigned int *)0x56000064 = 0x0000b020;
	*(volatile unsigned int *)0x56000068 = 0x0000ffff;
	*(volatile unsigned int *)0x5600006c = 0x00000000;
	*(volatile unsigned int *)0x56000070 = 0x00000aa0;
	*(volatile unsigned int *)0x56000074 = 0x0000013c;
	*(volatile unsigned int *)0x56000078 = 0x000007ff;
	*(volatile unsigned int *)0x5600007c = 0x00000000;
	*(volatile unsigned int *)0x56000080 = 0x00010330;
	*(volatile unsigned int *)0x56000084 = 0x00000000;
	*(volatile unsigned int *)0x56000088 = 0x00000000;
	*(volatile unsigned int *)0x5600008c = 0x00000000;
	*(volatile unsigned int *)0x56000090 = 0x00000000;
	*(volatile unsigned int *)0x56000094 = 0x00000000;
	*(volatile unsigned int *)0x56000098 = 0x00000000;
	*(volatile unsigned int *)0x5600009c = 0x00000000;
	*(volatile unsigned int *)0x560000a0 = 0x00000000;
	*(volatile unsigned int *)0x560000a4 = 0x00fffff0;
	*(volatile unsigned int *)0x560000a8 = 0x00080b00;
	*(volatile unsigned int *)0x560000ac = 0x0000000b;
	*(volatile unsigned int *)0x560000b0 = 0x32440001;
	*(volatile unsigned int *)0x560000b4 = 0x00000001;
	*(volatile unsigned int *)0x560000b8 = 0x00000000;
	*(volatile unsigned int *)0x560000bc = 0x00000000;
	*(volatile unsigned int *)0x560000c0 = 0x00b00000;
	*(volatile unsigned int *)0x560000c4 = 0x00000000;
	*(volatile unsigned int *)0x560000c8 = 0x00000000;
	*(volatile unsigned int *)0x560000cc = 0x00000000;
	*(volatile unsigned int *)0x560000d0 = 0x02aaaaaa;
	*(volatile unsigned int *)0x560000d4 = 0x000007ff;
	*(volatile unsigned int *)0x560000d8 = 0x00000000;
	*(volatile unsigned int *)0x560000dc = 0x00000000;
	*(volatile unsigned int *)0x560000e0 = 0x00000000;
	*(volatile unsigned int *)0x560000e4 = 0x00000000;
	*(volatile unsigned int *)0x560000e8 = 0x00000000;
	*(volatile unsigned int *)0x560000ec = 0x00000000;
	*(volatile unsigned int *)0x560000f0 = 0x00000000;
	*(volatile unsigned int *)0x560000f4 = 0x00000000;
	*(volatile unsigned int *)0x560000f8 = 0x00000000;
	*(volatile unsigned int *)0x560000fc = 0x00000000;

	*(volatile unsigned int *)0x4c000000 = 0x00ffffff;
	*(volatile unsigned int *)0x4c000004 = 0x00044011;
	*(volatile unsigned int *)0x4c000008 = 0x00038042;
	*(volatile unsigned int *)0x4c00000c = 0x00fffff0;
	*(volatile unsigned int *)0x4c000010 = 0x00000004;
	*(volatile unsigned int *)0x4c000014 = 0x00000007;
	*(volatile unsigned int *)0x4c000018 = 0x00000000;
	*(volatile unsigned int *)0x4c00001c = 0x00000000;
#endif	
	puts("uboot init regs finished \n");	
#if 0	
	*(volatile unsigned int *)0x56000020 = 0xaaaaaaaa;
	*(volatile unsigned int *)0x56000024 = 0x00000000;
	*(volatile unsigned int *)0x56000028 = 0x0000ffff;
	
	*(volatile unsigned int *)0x56000030 = 0xaaaaaaaa;
	*(volatile unsigned int *)0x56000034 = 0x00000000;
	*(volatile unsigned int *)0x56000038 = 0x0000ffff;
#endif
	puts("vga init\n");
	vga_init();
#if 1
	puts("lcd init\n");
	lcd_init();
	
	lcd_clear_screen(0x000000);	// black	

	puts("lcd draw line\n");
	lcd_draw_hline(100, 100, 640-100, 0xff0000);	// red
	lcd_draw_hline(200, 100, 640-100, 0x00ff00);	// green
	lcd_draw_hline(300, 100, 640-100, 0x0000ff);	// blue
	lcd_draw_hline(400, 100, 640-100, 0xffffff);	// white

	lcd_draw_vline(640/2, 50, 480-50, 0xffffff);	// white
	
	#define POS	50
	#define HALF	20
	lcd_draw_cross(POS, POS, HALF);
	lcd_draw_cross(POS, 640-POS, HALF);
	
	lcd_draw_cross(480-POS, POS, HALF);
	lcd_draw_cross(480-POS, 640-POS, HALF);
	
	puts("lcd test over\n");
#endif	
	//while (1);
	
	puts("nand init\n");
	// nand read 16M (size = 1M) to sdram  BMP_ADDR 0x33000000
	nand_init();
	
	// read bmp from 16M
	puts("nand read bmp 13M\n");
	nand_read(0x1000000, BMP_ADDR, 0xD00000);	
	puts("nand read bmp finished \n");
	
	// read wav from 32M
	nand_read(0x2000000, WAV_ADDR, 0x100000);
#if 0		
	// show BMP file
	puts("draw bmp file\n");	
	lcd_draw_bmp(BMP_ADDR);	
	lcd_clear_screen(0x000000);	// black	
	
	puts("draw bmp file using DMA \n");	
	lcd_draw_bmp_to_mem(BMP_ADDR, 0x33800000);
	dma_memcpy(0x33800000, 0x32000000, 0xFFFFF);
	puts("draw bmp file finished \n");
	
	audio_init();
	puts("play wav file\n");		
	play_wav(WAV_ADDR);		
	puts("play wav file finished \n");
	
	puts("play wav file with DMA \n");		
	dma_play_wav2(WAV_ADDR);		
	puts("play wav file with DMA finished \n");
#endif
	
	// deal with IRQ	
	*(int *)0x18 = 0xE59ff000;		// ldr pc, [pc]
	*(int *)0x20 = (int)dma_handler;
		
	// unmask 
	INTMSK &= ~(1<<19);
	
	// enable CPSR IRQ-bit
	// write to CPSR with value 0x53
	// CPSR = 0x53;
	__asm
	{	
		msr CPSR_cxsf, #0x53
	}
	
	while (1)
	{
		puts("while draw bmp file \n");
		lcd_draw_bmp(BMP_ADDR);	
		//lcd_clear_screen(0x000000);	// black	
		delay();
		
		dma_clear_lcd();		
	}
		
	//while (1)
	{	
			
	}
	
	
		
	while (1);
	
	return 0;
}
Ejemplo n.º 9
0
int mymain(void)
{	
	char * p = (char *)BMP_ADDR;
	char red, blue, green;
	int color;
	int i, j;
	
	vga_init();

	lcd_init();
	
	lcd_clear_screen(0x000000);	// black	
	
	draw_xy(0, 0, 0xff0000);
	draw_xy(0, 200, 0x00ff00);
	draw_xy(300, 0, 0x0000ff);

	for (i = -320; i < 320; i++)
		for (j = -240; j < 240; j++)
		{
			double x, y;
			int color = 0xff0000;
			
			x = (double)i / (double)150;
			y = (double)j / (double)150;
			
			color = get_fratal(x, y);
			
			draw_xy(i, j, color);
			//printf("i = %d, j = %d, color = %d \n", i, j, color);
		}
		
	while(1);
	

	lcd_draw_hline(100, 100, 640-100, 0xff0000);	// red
	lcd_draw_hline(200, 100, 640-100, 0x00ff00);	// green
	lcd_draw_hline(300, 100, 640-100, 0x0000ff);	// blue
	lcd_draw_hline(400, 100, 640-100, 0xffffff);	// white

	lcd_draw_vline(640/2, 50, 480-50, 0xffffff);	// white
	
	#define POS	50
	#define HALF	20
	lcd_draw_cross(POS, POS, HALF);
	lcd_draw_cross(POS, 640-POS, HALF);
	
	lcd_draw_cross(480-POS, POS, HALF);
	lcd_draw_cross(480-POS, 640-POS, HALF);
	
	//while (1);
	
	// show BMP file
		// read bmp file
	// bmp file header is 54 bytes
	p += 54;
	
	for (i = 0; i < 272; i++)
		for (j = 0; j < 480; j++)
		{
			blue = *p++;
			green = *p++;
			red = *p++;
		
			color = red << 16 | green << 8 | blue << 0;
			
			lcd_draw_pixel(272-i, j, color);
		}
	
	while (1);
	
	return 0;
}
Ejemplo n.º 10
0
int main()
{
	unsigned int num;

	
	unsigned char ret = 0;
	
	#ifdef  MMU_ON
	mmu_init();
	#endif
	led_init();
	key_init();
	irq_init();
	uart0_init();
	lcd_init();	
	i2c0_init();
	
		
	lcd_clear_screen(0x000000);
	dm9000_init();
	
	printf("First write address of 0x0,");
	at24cxx_write(0x0, 0xAA);  //往设备内存0地址写入0xAA
	ret = at24cxx_read(0x0);   //读设备内存0地址里面的数据
	printf("the value in address 0x0 = %x\r\n",ret);
	
	printf("Second write address of 0x1,");
	at24cxx_write(0x1,0x33);
	ret = at24cxx_read(0x1);
	printf("the value in address 0x1 = %x\r\n",ret);
	
	
	
//	dm9000_arp();
	
	while(1)
		{
			printf("\r\n");
			printf("========= Boot for S5pv210 Main Menu =========\r\n");
			printf("=========  designed by KungfuMonkey  =========\r\n");
			printf("\r\n");
			printf("1.ARP Request for PC MAC\r\n");
			printf("2.Download Linux Kernel to SDRAM\r\n");
			printf("3.Run the linux\r\n");
			
			scanf("%d\r\n",&num);
			printf("%d\r\n",num);
			
			
			switch(num)
			{
				case 1:
					arp_request();
					break;
					
				case 2:
					tftp_send_request("zImage");
					break;
					
				case 3:
				  boot_linux();					
					break;

					
				default:
					printf("Error: wrong selection!\r\n");
					break;
			}
		}
	return 0;
}
Ejemplo n.º 11
0
int main(int argc, const char *argv[])
{
	uint8_t ret;
	uint8_t init = 1;
	cfg_t *cfg;

       	int32_t adc_channel = -1;
	uint32_t val_cur[MCP32XX_MAX_CHANNEL], val_old[MCP32XX_MAX_CHANNEL];
	int32_t diff;

	struct mcp32xx_dev mcp_dev;
	struct volume_handle v_handle = {0};
	struct mpd_handle m_handle = {0};
	struct lcd_handle l_handle = {0};

	useconds_t sleep_usec;
	uint8_t song_update_count_max;
	uint8_t song_update_count = 0;

	cfg_opt_t opts[] = {
		CFG_INT("UpdateInterval", 300000, CFGF_NONE),
		CFG_INT("SongUpdateInterval", 2000000, CFGF_NONE),
		CFG_INT("ChannelUsed", 2, CFGF_NONE),
		CFG_INT("VolumeChannel", 0, CFGF_NONE),
		CFG_INT("TunerChannel", 1, CFGF_NONE),
		CFG_INT("MaxLineChar", 16, CFGF_NONE),
		CFG_INT("MaxLineBuf", 80, CFGF_NONE),
		CFG_STR("HostName", "localhost", CFGF_NONE),
		CFG_INT("Port", 6600, CFGF_NONE),
		CFG_INT("MaxTunerPos", 12, CFGF_NONE),
		CFG_INT("MaxVolSteps", 50, CFGF_NONE),
		CFG_STR("RadioPlaylistName", "stations", CFGF_NONE),
		CFG_INT("LCD-Pin_RS", 25, CFGF_NONE),
		CFG_INT("LCD-Pin_E", 24, CFGF_NONE),
		CFG_INT("LCD-Pin_DB4", 23, CFGF_NONE),
		CFG_INT("LCD-Pin_DB5", 17, CFGF_NONE),
		CFG_INT("LCD-Pin_DB6", 27, CFGF_NONE),
		CFG_INT("LCD-Pin_DB7", 22, CFGF_NONE),
		CFG_STR("FillPatternFirstLine", " ++ ", CFGF_NONE),
		CFG_STR("FillPatternSecondLine", " ** ", CFGF_NONE),
		CFG_INT("MaxLineLength", 16, CFGF_NONE),
		CFG_INT("MaxLineBufferLength", 80, CFGF_NONE),
        	CFG_END()
	};

	cfg = cfg_init(opts, CFGF_NONE);

	ret = cfg_parse(cfg, "/etc/radioberry.conf");
	if(ret == CFG_FILE_ERROR) {
		perror("/etc/radioberry.conf");
		printf("WARN: could not read /etc/radioberry.conf,"
				" process with default values\n");
	} else if (ret == CFG_PARSE_ERROR) {
		printf("configuration parse error\n");
		goto out;
	}

	/* get configuration values */
	channel_used = (uint8_t)cfg_getint(cfg, "ChannelUsed");
	volume_chan = (uint8_t)cfg_getint(cfg, "VolumeChannel");
	tuner_chan = (uint8_t)cfg_getint(cfg, "TunerChannel");

	sleep_usec = cfg_getint(cfg, "UpdateInterval") / channel_used;
	printf("sleep_usec %d\n", sleep_usec);
	song_update_count_max = cfg_getint(cfg, "SongUpdateInterval")
		/ sleep_usec;
	/* pass over pointer to handles of mpd, lcd and volume */
	m_handle.lh = &l_handle;
	v_handle.mh = &m_handle;

	m_handle.cfg = cfg;
	l_handle.cfg = cfg;

	signal(SIGINT, sigintterm_handler);
	signal(SIGTERM, sigintterm_handler);

	ret = lcd_init(&l_handle);
	if (ret) {
		printf("failed to initialize lcd, lcd control disabled \n");
		lcd_control_enabled = 0;
	}

	if (lcd_control_enabled) {
		lcd_print_string("Radioberry");
		lcd_move_cursor_down();
		lcd_print_string("=== Welcome ===");
	}

	ret = mcp32xx_init(&mcp_dev);
	if (ret) {
		printf("failed to initialize spi device, analog control"
				" devices disabled\n");
		tuner_control_enabled = 0;
		vol_control_enabled = 0;
	}

	ret = init_mpd_handle(&m_handle);
	if (ret) {
		printf("could not initialize mpd client,"
				" tuner control disabled\n");
		tuner_control_enabled = 0;
	}

	/* disable tuner control if we cannot get any station at all. If one
	 * station fails, let's process and wait for tuner changes */
	ret = load_stations_playlist(&m_handle);
	if (ret == 1) {
		printf("could not load radio stations list,"
				" tuner control disabled\n");
		tuner_control_enabled = 0;
	}

	ret = init_vol_control(&v_handle);
	if (ret) {
		printf("could not initialize volume control,"
				" volumen control disabled\n");
		vol_control_enabled = 0;
	}

	running = 1;

	while ( running ) {
		usleep(sleep_usec);

		if (adc_channel + 1 == channel_used) {
			adc_channel = 0;
			mpd_status_update(m_handle.mpd_obj);
			/* detect if initial loop is done. Start update lcd
			 * after initial loop */
			if (init)
				init = 0;
			else {
				if (lcd_control_enabled)
					lcd_update_screen(&l_handle);
			}
		} else
			adc_channel++;

		if (song_update_count == song_update_count_max) {
			update_song_info(&m_handle);
			song_update_count = 0;
		} else
			song_update_count++;

		/* loop over all channels in singel ended mode
		 * and reset counter in the last loop. */
		val_cur[adc_channel] = mcp32xx_get_val(&mcp_dev, adc_channel);

		/* fill the old value buffer and intialize the player with
		 * current settings*/
		if (init) {
			val_old[adc_channel] = val_cur[adc_channel];

			ret = process_value(&v_handle, &m_handle,
					val_cur[adc_channel], adc_channel);

			/* skip comparing old/new values while intializing */
			if (ret) {
				printf("unrecoverable error, quit now\n");
				break;
			}
			else
				continue;
		}

		diff = val_old[adc_channel] - val_cur[adc_channel];

#ifdef DEBUG
		printf("adc_channel: %u, old %u, new %u, diff %d\n",
				adc_channel, val_cur[adc_channel],
			       	val_old[adc_channel], diff);
#endif

		if (abs(diff) < TOLERANT_THRESHOLD)
			continue;
#ifdef DEBUG
		if (diff > 0)
			printf("Poti %u was turned left, current val: %d\n",
				adc_channel + 1, val_cur[adc_channel]);
		else
			printf("Poti %u was turned right, current Pos: %d\n",
				adc_channel + 1, val_cur[adc_channel]);
#endif
		process_value(&v_handle, &m_handle, val_cur[adc_channel],
				adc_channel);
		val_old[adc_channel] = val_cur[adc_channel];
	}
out:
	lcd_clear_screen();
	lcd_close(&l_handle);
	mcp32xx_close(&mcp_dev);
	close_vol_ctl(&v_handle);
	close_mpd_handle(&m_handle);

	exit(ret);
}