view src/cs/drivers/drv_app/r2d/lcds/c139/r2d_task_i.c @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents 4221c724c664
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)
{
}

void r2d_refresh(void)
{
	UINT16 i, j, k;
	UINT32 v;
	UINT32 *p;
	INT16 y1, y2;

	p=r2d_g_framebuffer->p_memory_words;
    
	y1=r2d_update_ul_y; //0
	y2=r2d_update_br_y; //63

	if (y1 > y2)
		return;
	r2d_reinit_update_region();

	/* set window area */
	c139_set_lcd_addr_region(0, 95, y1, y2);

	p=p+y1*R2D_MWWIDTH;

	for (i=y1;i<=y2;i++)
	{
		for (j = 0; j < R2D_MWWIDTH-1; j++)
		{
			v=*p++;
			for (k=0;k<32;k++)
			{
				if (v&1)
					c139_lcd_send_pix(LCD16_COLOR_BLACK);
				else
					c139_lcd_send_pix(LCD16_COLOR_WHITE);
				v=v>>1;
			}
		}	    
		p++;
	} 
}