view src/cs/drivers/drv_app/r2d/lcds/c139/r2d_task_init_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 502a0a3f6a49
children
line wrap: on
line source

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

#define R2D_MB_PRIM_SIZE 4000

extern void c139_lcd_ctrl_cmd(UINT8 cmd, UINT8 param);
extern void c139_set_lcd_addr_region(UINT8 xstart, UINT8 xend,
					UINT8 ystart, UINT8 yend);
extern void c139_lcd_send_pix(UINT16 pixval);

void uwire_init_lcd(void)
{
	* ( UINT16 *) CNTL_RST &= ~(0x04); // releases reset_out
	* ( UINT16 *) CNTL_RST |= (0x04); // set reset_out to 0
	rvf_delay(RVF_MS_TO_TICKS(5));    // waits for 5 ms
	* ( UINT16 *) CNTL_RST &= ~(0x04); // releases reset_out

	* (volatile UINT16 *) SR1 = CS0_FRQ_FINT_2;
	* (volatile UINT16 *) SR3 = SR3_CLK_EN; // enables the uwire clock
	* (volatile UINT16 *) CSR = INDEX_CS0; // selects CS0
}

static void r2d_refresh_task_init(void)
{
	UINT16 i;

	uwire_init_lcd();
	rvf_delay(RVF_MS_TO_TICKS(5));    // waits for 5 ms

	/* LCD controller init */
	c139_lcd_ctrl_cmd(0x3F, 0x01);
	c139_lcd_ctrl_cmd(0x20, 0x03);
	c139_lcd_ctrl_cmd(0x31, 0x03);

	/* initial hw framebuffer clearing */
	c139_set_lcd_addr_region(0, 95, 0, 63);
	for (i = 0; i < 96 * 64; i++)
		c139_lcd_send_pix(LCD16_COLOR_WHITE);
}

static void r2d_refresh_task_kill(void)
{
}

static void r2d_dithering_init(void)
{
   R2D_MALLOC(r2d_mb_id,UINT32,sizeof(UINT32)*4,r2d_g_dithering_matrix);
   r2d_g_dithering_matrix[0]=0;
   r2d_g_dithering_matrix[1]=2;
   r2d_g_dithering_matrix[2]=3;
   r2d_g_dithering_matrix[3]=1;
}