view chipsetsw/drivers/drv_app/r2d/lcds/c139/r2d_task_i.c @ 48:616f63f3e501 default tip

fixed bug in etm_pkt_send() dealing with max-sized packets: this fix is needed for fc-fsio cpout command to work like it does with Pirelli's firmware (they must have made the same fix)
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Fri, 13 Nov 2015 19:11:07 +0000
parents f1ffea823c18
children
line wrap: on
line source

#include "r2d/lcds/c139/colors.h"

void c139_uwire_xmit(UINT16 cmd)
{
	* (volatile UINT16 *) TDR = cmd << 7;
	* (volatile UINT16 *) CSR |= NB_BITS_WR_9 + CS_CMD + START ; // transmit command data
	while (((* (volatile UINT16 *) CSR) & CSRB) != 0 ); // wait for end of WRITE
	* (volatile UINT16 *) CSR &= ~CS_CMD; // clears Chip Select 	
}

void c139_lcd_ctrl_cmd(UINT8 cmd, UINT8 param)
{
	c139_uwire_xmit(cmd);
	c139_uwire_xmit(param | 0x100);
}

void c139_set_lcd_addr_region(UINT8 xstart, UINT8 xend,
				UINT8 ystart, UINT8 yend)
{
	c139_lcd_ctrl_cmd(0x10, xstart);
	c139_lcd_ctrl_cmd(0x11, ystart);
	c139_lcd_ctrl_cmd(0x12, xend);
	c139_lcd_ctrl_cmd(0x13, yend);
	c139_lcd_ctrl_cmd(0x14, xstart);
	c139_lcd_ctrl_cmd(0x15, ystart);
}

void c139_lcd_send_pix(UINT16 pixval)
{
	c139_uwire_xmit((pixval >> 8) | 0x100);
	c139_uwire_xmit((pixval & 0xFF) | 0x100);
}

void r2d_lcd_power_on(void)
{
}

void r2d_lcd_power_off(void)
{
}

static int get_pix_from_sw_fb(UINT32 *fb, UINT16 x, UINT16 y)
{
	UINT32 *p, mask;
	UINT16 yword, ybit;

	/* mirroring */
	x = R2D_WIDTH - x;
	y = R2D_HEIGHT - y;
	yword = y >> 5;
	ybit = y & 31;
	p = fb + x * R2D_MWHEIGHT + yword;
	mask = 1 << ybit;
	if (*p & mask)
		return(1);
	else
		return(0);
}

void r2d_refresh(void)
{
	UINT16 x, y;
	UINT32 *fb;

	fb = r2d_g_framebuffer->p_memory_words;

	/* set the LCD up to refresh the 84x48 area */
	c139_set_lcd_addr_region(6, 89, 8, 55);
	/* send the pixels */
	for (y = 0; y < R2D_HEIGHT; y++) {
		for (x = 0; x < R2D_WIDTH; x++) {
			if (get_pix_from_sw_fb(fb, x, y))
				c139_lcd_send_pix(LCD16_COLOR_BLACK);
			else
				c139_lcd_send_pix(LCD16_COLOR_WHITE);
		}
	}

	r2d_reinit_update_region();
}