view src/cs/drivers/drv_app/r2d/lcds/luna/r2d_onoff_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 75758d7a9be3
children
line wrap: on
line source

#include "r2d/lcds/luna/r2d_luna_lcd.h"
#include "main/sys_types.h"
#include "armio.h"

static void lcd_suspend(void)
{
	if (r2d_lcd_hw_suspend)
		return;		/* already in suspend */
	r2d_lcd_hw_suspend = 1;
	LCD_REG_WR(0x0007, 0);			/* display off */
	rvf_delay(RVF_MS_TO_TICKS(50));
	LCD_REG_WR(0x0010, 1);			/* suspend mode */
	ABB_sleep_allowed = 1;
}

static void lcd_resume(void)
{
	if (!r2d_lcd_hw_suspend)
		return;		/* already on */
	ABB_sleep_allowed = 0;
	LCD_REG_WR(0x0010, 0);			/* out of suspend */
	rvf_delay(RVF_MS_TO_TICKS(50));
	LCD_REG_WR(0x0007, 0x1017);		/* display on */
	r2d_lcd_hw_suspend = 0;
	r2d_refresh();
}

static void r2d_onoff_action(enum blrr_display_state set_state)
{
	UBYTE on_off;

	/*
	 * PWL control: on our current Luna setups (Caramel2 or iWOW DSK)
	 * PWL is only an indicator LED for developers.  We use this PWL
	 * indicator to show the state of "virtual dimming", as there is
	 * no physical LCD backlight dimming control on Luna.
	 */
	switch (set_state) {
	case BLRR_DISPLAY_OFF:
		*(volatile SYS_UWORD8 *)0xFFFE8000 = 0;
		*(volatile SYS_UWORD8 *)0xFFFE8001 = 0;
		on_off = 0;
		break;
	case BLRR_DISPLAY_ON:
		*(volatile SYS_UWORD8 *)0xFFFE8000 = 255;
		*(volatile SYS_UWORD8 *)0xFFFE8001 = 1;
		on_off = 1;
		break;
	case BLRR_DISPLAY_INCALL:
		*(volatile SYS_UWORD8 *)0xFFFE8000 = 16;
		*(volatile SYS_UWORD8 *)0xFFFE8001 = 1;
		on_off = 1;
		break;
	case BLRR_DISPLAY_CHG_BOOT:
		*(volatile SYS_UWORD8 *)0xFFFE8000 = 64;
		*(volatile SYS_UWORD8 *)0xFFFE8001 = 1;
		on_off = 1;
		break;
	default:
		return;		/* error, but we are a void function */
	}
	/* physical LCD and backlight on/off */
	if (on_off) {
		lcd_resume();
		AI_SetBit(9);
	} else {
		AI_ResetBit(9);
		lcd_suspend();
	}
}