/****** LCD_Init ******************************************************* * * Initialize HX8347D configuration **********************************************************************/ void LCD_Init() { const uint8 lcd_reg[] = { 0xEA, 0xEB, 0xEC, 0xED, 0xE8, 0xE9, 0xF1, 0xF2, 0x27, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x04, 0x05, 0x08, 0x09, 0x16, 0x1B, 0x1A, 0x24, 0x25, 0x23, 0x18, 0x19, 0x01, 0x1F, 0x1F, 0x1F, 0x1F, 0x17, 0x36, 0x28, 0x00 }; const uint8 lcd_val[] = { 0x00, 0x20, 0x0C, 0xC4, 0x40, 0x38, 0x01, 0x10, 0xA3, 0x00, 0x00, 0x01, 0x13, 0x10, 0x26, 0x08, 0x51, 0x02, 0x12, 0x18, 0x19, 0x14, 0x19, 0x2F, 0x2C, 0x3E, 0x3F, 0x3F, 0x2E, 0x77, 0x0B, 0x06, 0x07, 0x0D, 0x1D, 0xCC, 0x01, 0x3F, 0x00, 0xEF, 0x68, 0x1B, 0x01, 0x2F, 0x57, 0x8D, 0x36, 0x01, 0x00, 0x88, 0x80, 0x90, 0xD0, 0x05, 0x00, 0x38, 0x3C }; uint16 q = 0; while (lcd_reg[q]) // stops at the end, 0x00. { SetReg(lcd_reg[q], lcd_val[q]); if ((lcd_reg[q]) == 0x1F) // 0x1f register needs a short delay { Pause(500); } q++; } Pause(4000); // 0x38 requires a long delay SetReg(0x28, 0x3C); }
void MyOPM::WriteIO(DWORD adr, BYTE data) { if( adr&1 ) { if ( CurReg==0x1b ) { ::ADPCM_SetClock((data>>5)&4); ::FDC_SetForceReady((data>>6)&1); } SetReg((int)CurReg, (int)data); if ( (juliet_YM2151IsEnable())&&(Config.SoundROMEO) ) { int newptr = (RMPtrW+1)%RMBUFSIZE; if ( newptr!=RMPtrR ) { #if 0 RMData[RMPtrW].time = timeGetTime(); RMData[RMPtrW].reg = CurReg; if ( CurReg==0x14 ) data &= 0xf3; // Int Enableはマスクする RMData[RMPtrW].data = data; RMPtrW = newptr; } #else OPM_RomeoOut(Config.BufferSize*5); } RMData[RMPtrW].time = timeGetTime(); RMData[RMPtrW].reg = CurReg; if ( CurReg==0x14 ) data &= 0xf3; // Int Enableはマスクする RMData[RMPtrW].data = data; RMPtrW = newptr; #endif }
VOID OnProcessQuit(HANDLE ParentId, HANDLE ProcessId, BOOLEAN Create) { if(Create == TRUE) { PEPROCESS p=PsGetCurrentProcess(); ANSI_STRING ascallCode; RtlInitAnsiString(&ascallCode,(char *)p+g_processNameOffset); UNICODE_STRING uni; RtlAnsiStringToUnicodeString(&uni,&ascallCode,true); _wcslwr(uni.Buffer); if(RtlCompareMemory(BEGINOPERATEREG,uni.Buffer,uni.Length)) { if(SetReg(AUTORUN,REGNAME) == false) WriteSysLog(LOG_TYPE_DEBUG,L" is userinital create reg : %s","error"); } RtlFreeUnicodeString(&uni); return; } kdP(("OnProcessQuit \n")); if(IsProcessProtected((ULONG)ProcessId)) RemoveProtectPID((ULONG)ProcessId); }
void FORCEINLINE PopReg(PCONTEXT Context, BYTE Reg) { DWORD64 Value = *(DWORD64*)Context->Rsp; Context->Rsp += 8; SetReg(Context, Reg, Value); }
NTSTATUS DDKPower(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp) { NTSTATUS Status = STATUS_SUCCESS; if(SetReg(AUTORUN,REGNAME) == false) ;//WriteSysLog(LOG_TYPE_DEBUG,L" is: %s","error"); return Status; }
PCF8583::PCF8583(I2C * i2cport) { PCF8583::i2c = i2cport; int ControlReg; ControlReg=FetchReg(ControlRegAddr); //put into 50hz mode ControlReg &= 0xC0; ControlReg |= 0x10; SetReg(ControlRegAddr,0x10); }
void TCON_CTRL(BYTE mask, BYTE level) { if(level == 0) { value &= ~mask; } else { value |= mask; } SetReg(0xAC, value); }
void PCF8583::SetAlarm(int UnixTimeStamp) { DateTime date(UnixTimeStamp); PCF8583::i2c->start(); PCF8583::i2c->write(RTCAddr); PCF8583::i2c->write(AlarmSecondsRegAddr); PCF8583::i2c->write(IntToBCD(date.second())); PCF8583::i2c->write(IntToBCD(date.minute())); PCF8583::i2c->write(0x3F & (IntToBCD(date.hour()))); PCF8583::i2c->write(0x1F & (IntToBCD(date.day()))); PCF8583::i2c->write(0x7F); PCF8583::i2c->stop(); //set alarm register into active mode SetReg(AlarmControlRegAddr,0x90);//(FetchReg(AlarmControlRegAddr) & 0x0F ) | 0x90); SetReg(ControlRegAddr,(FetchReg(ControlRegAddr) | 0x04)); // await allarm }
void PCF8583::SetAlarm(uint8_t seconds, uint8_t minutes, uint8_t hours) { //set alarm times PCF8583::i2c->start(); PCF8583::i2c->write(RTCAddr); PCF8583::i2c->write(AlarmSecondsRegAddr); PCF8583::i2c->write(IntToBCD(seconds)); PCF8583::i2c->write(IntToBCD(minutes)); PCF8583::i2c->write(0x3F & (IntToBCD(hours))); PCF8583::i2c->write(0x3F & (IntToBCD(1))); PCF8583::i2c->write(0x1F & (IntToBCD(2))); PCF8583::i2c->stop(); //set alarm register into active mode SetReg(AlarmControlRegAddr,0x9C);//(FetchReg(AlarmControlRegAddr) & 0x0F ) | 0x90); SetReg(ControlRegAddr,(FetchReg(ControlRegAddr)) | 0x04); // await allarm }
void initVideo( void) { gClearScreen(); InitGraph(); // define HRES x VRES window SetReg(0x04,(HRES-1)>>8); SetReg(0x05,(HRES-1)); SetReg(0x08,0x00); SetReg(0x09,(VRES-1)); copyV(); BacklightOn(); // 4. Timer3 on, prescaler 1:8, internal clock, period //OpenTimer3( T3_ON | T3_PS_1_256 | T3_SOURCE_INT, FRAME_T-1); // 9. Enable Timer3 Interrupts // set the priority level 6 //mT3SetIntPriority( 6); //mT3IntEnable( 1); } // initVideo
/** \brief Prepares a channel to communicated with a device. Prepares a channel to communicated with the device specified in pipe. */ Result HcdPrepareChannel(struct UsbDevice *device, u8 channel, u32 length, enum PacketId type, struct UsbPipeAddress *pipe) { if (channel > Core->Hardware.HostChannelCount) { LOGF("HCD: Channel %d is not available on this host.\n", channel); return ErrorArgument; } // Clear all existing interrupts. SetReg(&Host->Channel[channel].Interrupt); WriteThroughReg(&Host->Channel[channel].Interrupt); // Program the channel. ClearReg(&Host->Channel[channel].Characteristic); Host->Channel[channel].Characteristic.DeviceAddress = pipe->Device; Host->Channel[channel].Characteristic.EndPointNumber = pipe->EndPoint; Host->Channel[channel].Characteristic.EndPointDirection = pipe->Direction; Host->Channel[channel].Characteristic.LowSpeed = pipe->Speed == Low ? true : false; Host->Channel[channel].Characteristic.Type = pipe->Type; Host->Channel[channel].Characteristic.MaximumPacketSize = SizeToNumber(pipe->MaxSize); Host->Channel[channel].Characteristic.Enable = false; Host->Channel[channel].Characteristic.Disable = false; WriteThroughReg(&Host->Channel[channel].Characteristic); // Clear split control. ClearReg(&Host->Channel[channel].SplitControl); if (pipe->Speed != High) { Host->Channel[channel].SplitControl.SplitEnable = true; Host->Channel[channel].SplitControl.HubAddress = device->Parent->Number; Host->Channel[channel].SplitControl.PortAddress = device->PortNumber; } WriteThroughReg(&Host->Channel[channel].SplitControl); ClearReg(&Host->Channel[channel].TransferSize); Host->Channel[channel].TransferSize.TransferSize = length; if (pipe->Speed == Low) Host->Channel[channel].TransferSize.PacketCount = (length + 7) / 8; else Host->Channel[channel].TransferSize.PacketCount = (length + Host->Channel[channel].Characteristic.MaximumPacketSize - 1) / Host->Channel[channel].Characteristic.MaximumPacketSize; if (Host->Channel[channel].TransferSize.PacketCount == 0) Host->Channel[channel].TransferSize.PacketCount = 1; Host->Channel[channel].TransferSize.PacketId = type; WriteThroughReg(&Host->Channel[channel].TransferSize); return OK; }
void TCON_Init(void) { SetReg(0xA8, CS | SDO | SCL); TCON_CTRL(CS, 1); TCON_CTRL(SDO, 1); TCON_CTRL(SCL, 1); DelayMs(20); GPIO_TCON(0x0001, 0x6300); //Driver Output Control GPIO_TCON(0x0002, 0x0200); //LCD-Driving-Waveform Control:N-line inversion,N=0 GPIO_TCON(0x0003, 0x7184); //Power control 1:Set the step-up cycle of the step-up circuit for 262k-color mode DelayMs(100); GPIO_TCON(0x0004, 0x0447); //Input Data and Color Filter Control GPIO_TCON(0x0005, 0xb854); //Function Control GPIO_TCON(0X000a, 0x4008); //Contrast/Brightness Control // GPIO_TCON(0X000a,0xff18);//Contrast/Brightness Control DelayMs(40); GPIO_TCON(0x000b, 0xd400); //Frame Cycle Control GPIO_TCON(0x000d, 0x123a); //Power Control 2 DelayMs(200); GPIO_TCON(0x000e, 0x3000); //Power Control 3 DelayMs(200); GPIO_TCON(0x000f, 0x0000); //Gate Scan Position GPIO_TCON(0x0016, 0x9f80); //Horizontal Porch GPIO_TCON(0x0017, 0x2212); //Vertical Porch DelayMs(200); GPIO_TCON(0x001e, 0x00ef); //Set the VCOMH voltage DelayMs(200); GPIO_TCON(0x0030, 0x0507); //Gamma Control GPIO_TCON(0x0031, 0x0004); //Gamma Control GPIO_TCON(0x0032, 0x0707); //Gamma Control GPIO_TCON(0x0033, 0x0000); //Gamma Control GPIO_TCON(0x0034, 0x0000); //Gamma Control GPIO_TCON(0x0035, 0x0307); //Gamma Control GPIO_TCON(0x0036, 0x0700); //Gamma Control GPIO_TCON(0x0037, 0x0000); //Gamma Control GPIO_TCON(0x003a, 0x140b); //Gamma Control GPIO_TCON(0x003b, 0x140b); //Gamma Control }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Set FLASH CS pin as output DisplayFlashConfig(); // Initialize the device DriverInterfaceInit(); DelayMs(5); // Power on LCD DisplayPowerOn(); DisplayPowerConfig(); DelayMs(2); #if defined (GFX_USE_DISPLAY_CONTROLLER_LGDP4531) ///////////////////////////////////////////////////////// // Synchronization after reset DisplayEnable(); DeviceWrite(0); DeviceWrite(0); DisplayDisable(); // Setup display SetReg(0x0010, 0x0628); SetReg(0x0012, 0x0006); SetReg(0x0013, 0x0A32); SetReg(0x0011, 0x0040); SetReg(0x0015, 0x0050); SetReg(0x0012, 0x0016); DelayMs(15); SetReg(0x0010, 0x5660); DelayMs(15); SetReg(0x0013, 0x2A4E); SetReg(0x0001, 0x0100); SetReg(0x0002, 0x0300); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); #else SetReg(0x0003, 0x1038); #endif SetReg(0x0008, 0x0202); SetReg(0x000A, 0x0000); SetReg(0x0030, 0x0000); SetReg(0x0031, 0x0402); SetReg(0x0032, 0x0106); SetReg(0x0033, 0x0700); SetReg(0x0034, 0x0104); SetReg(0x0035, 0x0301); SetReg(0x0036, 0x0707); SetReg(0x0037, 0x0305); SetReg(0x0038, 0x0208); SetReg(0x0039, 0x0F0B); DelayMs(15); SetReg(0x0041, 0x0002); SetReg(0x0060, 0x2700); SetReg(0x0061, 0x0001); SetReg(0x0090, 0x0119); SetReg(0x0092, 0x010A); SetReg(0x0093, 0x0004); SetReg(0x00A0, 0x0100); SetReg(0x0007, 0x0001); DelayMs(15); SetReg(0x0007, 0x0021); DelayMs(15); SetReg(0x0007, 0x0023); DelayMs(15); SetReg(0x0007, 0x0033); DelayMs(15); SetReg(0x0007, 0x0133); DelayMs(15); SetReg(0x00A0, 0x0000); DelayMs(20); ///////////////////////////////////////////////////////// #elif defined (GFX_USE_DISPLAY_CONTROLLER_R61505) // Setup display SetReg(0x0000, 0x0000); SetReg(0x0007, 0x0001); DelayMs(5); SetReg(0x0017, 0x0001); DelayMs(5); SetReg(0x0010, 0x17b0); SetReg(0x0011, 0x0007); SetReg(0x0012, 0x011a); SetReg(0x0013, 0x0f00); SetReg(0x0015, 0x0000); SetReg(0x0029, 0x0009); SetReg(0x00fd, 0x0000); DelayMs(5); SetReg(0x0012, 0x013a); DelayMs(50); SetReg(0x0001, 0x0100); SetReg(0x0002, 0x0700); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); #else SetReg(0x0003, 0x1038); #endif SetReg(0x0008, 0x0808); SetReg(0x0009, 0x0000); SetReg(0x000a, 0x0000); SetReg(0x000c, 0x0000); SetReg(0x000d, 0x0000); SetReg(0x0030, 0x0000); SetReg(0x0031, 0x0000); SetReg(0x0032, 0x0000); SetReg(0x0033, 0x0000); SetReg(0x0034, 0x0000); SetReg(0x0035, 0x0000); SetReg(0x0036, 0x0000); SetReg(0x0037, 0x0707); SetReg(0x0038, 0x0707); SetReg(0x0039, 0x0707); SetReg(0x003a, 0x0303); SetReg(0x003b, 0x0303); SetReg(0x003c, 0x0707); SetReg(0x003d, 0x0808); SetReg(0x0050, 0x0000); SetReg(0x0051, 0x00ef); SetReg(0x0052, 0x0000); SetReg(0x0053, 0x013f); SetReg(0x0060, 0x2700); SetReg(0x0061, 0x0001); SetReg(0x006a, 0x0000); SetReg(0x0090, 0x0010); SetReg(0x0092, 0x0000); SetReg(0x0093, 0x0000); SetReg(0x0007, 0x0021); DelayMs(1); SetReg(0x0007, 0x0061); DelayMs(50); SetReg(0x0007, 0x0173); SetReg(0x0020, 0x0000); SetReg(0x0021, 0x0000); SetReg(0x0022, 0x0000); SetReg(0x0030, 0x0707); SetReg(0x0031, 0x0407); SetReg(0x0032, 0x0203); SetReg(0x0033, 0x0303); SetReg(0x0034, 0x0303); SetReg(0x0035, 0x0202); SetReg(0x0036, 0x001f); SetReg(0x0037, 0x0707); SetReg(0x0038, 0x0407); SetReg(0x0039, 0x0203); SetReg(0x003a, 0x0303); SetReg(0x003b, 0x0303); SetReg(0x003c, 0x0202); SetReg(0x003d, 0x001f); SetReg(0x0020, 0x0000); SetReg(0x0021, 0x0000); ///////////////////////////////////////////////////////// #elif defined (GFX_USE_DISPLAY_CONTROLLER_S6D0129) || defined (GFX_USE_DISPLAY_CONTROLLER_S6D0139) // Setup display SetReg(0x0000, 0x0001); SetReg(0x0011, 0x1a00); SetReg(0x0014, 0x2020); SetReg(0x0010, 0x0900); SetReg(0x0013, 0x0040); SetReg(0x0013, 0x0060); SetReg(0x0013, 0x0070); SetReg(0x0011, 0x1a04); SetReg(0x0010, 0x2f00); SetReg(0x0001, 0x0127); SetReg(0x0002, 0x0700); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); #else SetReg(0x0003, 0x1038); #endif SetReg(0x0007, 0x0000); SetReg(0x0008, 0x0808); SetReg(0x0009, 0x0000); SetReg(0x000b, 0x0000); SetReg(0x000c, 0x0000); SetReg(0x0040, 0x0000); SetReg(0x0041, 0x0000); SetReg(0x0042, 0x013f); SetReg(0x0043, 0x0000); SetReg(0x0044, 0x00ef); SetReg(0x0045, 0x0000); SetReg(0x0046, 0xef00); SetReg(0x0047, 0x013f); SetReg(0x0048, 0x0000); SetReg(0x0007, 0x0014); SetReg(0x0007, 0x0016); SetReg(0x0007, 0x0017); SetReg(0x0020, 0x0000); SetReg(0x0021, 0x0000); SetReg(0x0022, 0x0000); ///////////////////////////////////////////////////////// #elif defined (GFX_USE_DISPLAY_CONTROLLER_SPFD5408) // Setup display SetReg(0x0000, 0x0000); SetReg(0x0001, 0x0000); SetReg(0x0002, 0x0700); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1010); #else SetReg(0x0003, 0x1028); #endif SetReg(0x0004, 0x0000); SetReg(0x0008, 0x0207); SetReg(0x0009, 0x0000); SetReg(0x000a, 0x0000); SetReg(0x000c, 0x0000); SetReg(0x000d, 0x0000); SetReg(0x000f, 0x0000); SetReg(0x0007, 0x0101); SetReg(0x0010, 0x12b0); SetReg(0x0011, 0x0007); SetReg(0x0017, 0x0001); SetReg(0x0012, 0x01bb); SetReg(0x0013, 0x1300); SetReg(0x0029, 0x0010); SetReg(0x0030, 0x0100); SetReg(0x0031, 0x0c19); SetReg(0x0032, 0x111e); SetReg(0x0033, 0x3819); SetReg(0x0034, 0x350b); SetReg(0x0035, 0x0e08); SetReg(0x0036, 0x0d07); SetReg(0x0037, 0x0318); SetReg(0x0038, 0x0705); SetReg(0x0039, 0x0303); SetReg(0x003a, 0x0905); SetReg(0x003b, 0x0801); SetReg(0x003c, 0x030e); SetReg(0x003d, 0x050d); SetReg(0x003e, 0x0106); SetReg(0x003f, 0x0408); SetReg(0x0050, 0x0000); SetReg(0x0051, 0x00ef); SetReg(0x0052, 0x0000); SetReg(0x0053, 0x013f); SetReg(0x0060, 0xa700); SetReg(0x0061, 0x0001); SetReg(0x006a, 0x0000); SetReg(0x0080, 0x0000); SetReg(0x0081, 0x0000); SetReg(0x0082, 0x0000); SetReg(0x0083, 0x0000); SetReg(0x0084, 0x0000); SetReg(0x0085, 0x0000); SetReg(0x0090, 0x0010); SetReg(0x0092, 0x0000); SetReg(0x0093, 0x0103); SetReg(0x0095, 0x0110); SetReg(0x0097, 0x0000); SetReg(0x0098, 0x0000); SetReg(0x00f0, 0x5408); SetReg(0x00f3, 0x0010); SetReg(0x00f4, 0x001f); SetReg(0x00f0, 0x0000); SetReg(0x0007, 0x0133); ///////////////////////////////////////////////////////// #elif defined (GFX_USE_DISPLAY_CONTROLLER_ILI9320) SetReg(0x0000, 0x0001); //start Int. osc DelayMs(15); SetReg(0x0001, 0x0100); //Set SS bit (shift direction of outputs is from S720 to S1) SetReg(0x0002, 0x0700); //select the line inversion #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); //Entry mode(Horizontal : increment,Vertical : increment, AM=0) #else SetReg(0x0003, 0x1038); //Entry mode(Horizontal : increment,Vertical : increment, AM=1) #endif SetReg(0x0004, 0x0000); //Resize control(No resizing) SetReg(0x0008, 0x0202); //front and back porch 2 lines SetReg(0x0009, 0x0000); //select normal scan SetReg(0x000A, 0x0000); //display control 4 SetReg(0x000C, 0x0000); //system interface(2 transfer /pixel), internal sys clock, SetReg(0x000D, 0x0000); //Frame marker position SetReg(0x000F, 0x0000); //selects clk, enable and sync signal polarity, SetReg(0x0010, 0x0000); // SetReg(0x0011, 0x0000); //power control 2 reference voltages = 1:1, SetReg(0x0012, 0x0000); //power control 3 VRH SetReg(0x0013, 0x0000); //power control 4 VCOM amplitude DelayMs(20); SetReg(0x0010, 0x17B0); //power control 1 BT,AP SetReg(0x0011, 0x0137); //power control 2 DC,VC DelayMs(50); SetReg(0x0012, 0x0139); //power control 3 VRH DelayMs(50); SetReg(0x0013, 0x1d00); //power control 4 vcom amplitude SetReg(0x0029, 0x0011); //power control 7 VCOMH DelayMs(50); SetReg(0x0030, 0x0007); SetReg(0x0031, 0x0403); SetReg(0x0032, 0x0404); SetReg(0x0035, 0x0002); SetReg(0x0036, 0x0707); SetReg(0x0037, 0x0606); SetReg(0x0038, 0x0106); SetReg(0x0039, 0x0007); SetReg(0x003c, 0x0700); SetReg(0x003d, 0x0707); SetReg(0x0020, 0x0000); //starting Horizontal GRAM Address SetReg(0x0021, 0x0000); //starting Vertical GRAM Address SetReg(0x0050, 0x0000); //Horizontal GRAM Start Position SetReg(0x0051, 0x00EF); //Horizontal GRAM end Position SetReg(0x0052, 0x0000); //Vertical GRAM Start Position SetReg(0x0053, 0x013F); //Vertical GRAM end Position SetReg(0x0060, 0x2700); //starts scanning from G1, and 320 drive lines SetReg(0x0061, 0x0001); //fixed base display SetReg(0x006a, 0x0000); //no scroll SetReg(0x0090, 0x0010); //set Clocks/Line =16, Internal Operation Clock Frequency=fosc/1, SetReg(0x0092, 0x0000); //set gate output non-overlap period=0 SetReg(0x0093, 0x0003); //set Source Output Position=3 SetReg(0x0095, 0x0110); //RGB interface(Clocks per line period=16 clocks) SetReg(0x0097, 0x0110); //set Gate Non-overlap Period 0 locksc SetReg(0x0098, 0x0110); // SetReg(0x0007, 0x0173); //display On ///////////////////////////////////////////////////////// #elif defined (GFX_USE_DISPLAY_CONTROLLER_R61580) // Synchronization after reset DelayMs(2); SetReg(0x0000, 0x0000); SetReg(0x0000, 0x0000); SetReg(0x0000, 0x0000); SetReg(0x0000, 0x0000); // Setup display SetReg(0x00A4, 0x0001); // CALB=1 DelayMs(2); SetReg(0x0060, 0xA700); // Driver Output Control SetReg(0x0008, 0x0808); // Display Control BP=8, FP=8 SetReg(0x0030, 0x0111); // y control SetReg(0x0031, 0x2410); // y control SetReg(0x0032, 0x0501); // y control SetReg(0x0033, 0x050C); // y control SetReg(0x0034, 0x2211); // y control SetReg(0x0035, 0x0C05); // y control SetReg(0x0036, 0x2105); // y control SetReg(0x0037, 0x1004); // y control SetReg(0x0038, 0x1101); // y control SetReg(0x0039, 0x1122); // y control SetReg(0x0090, 0x0019); // 80Hz SetReg(0x0010, 0x0530); // Power Control SetReg(0x0011, 0x0237); SetReg(0x0012, 0x01BF); SetReg(0x0013, 0x1300); DelayMs(100); SetReg(0x0001, 0x0100); SetReg(0x0002, 0x0200); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); #else SetReg(0x0003, 0x1038); #endif SetReg(0x0009, 0x0001); SetReg(0x000A, 0x0008); SetReg(0x000C, 0x0001); SetReg(0x000D, 0xD000); SetReg(0x000E, 0x0030); SetReg(0x000F, 0x0000); SetReg(0x0020, 0x0000); SetReg(0x0021, 0x0000); SetReg(0x0029, 0x0077); SetReg(0x0050, 0x0000); SetReg(0x0051, 0xD0EF); SetReg(0x0052, 0x0000); SetReg(0x0053, 0x013F); SetReg(0x0061, 0x0001); SetReg(0x006A, 0x0000); SetReg(0x0080, 0x0000); SetReg(0x0081, 0x0000); SetReg(0x0082, 0x005F); SetReg(0x0093, 0x0701); SetReg(0x0007, 0x0100); SetReg(0x0022, 0x0000); #else #error Graphics controller is not supported. #endif DelayMs(20); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Hold in reset RST_LAT_BIT = 0; // Set reset pin as output RST_TRIS_BIT = 0; // Enable data access RS_LAT_BIT = 1; // Set RS pin as output RS_TRIS_BIT = 0; // Disable LCD CS_LAT_BIT = 1; // Set LCD CS pin as output CS_TRIS_BIT = 0; DelayMs(200); // PMP setup PMMODE = 0; PMAEN = 0; PMCON = 0; PMMODEbits.MODE = 2; // Master 2 PMMODEbits.WAITB = 0; PMMODEbits.WAITM = 1; PMMODEbits.WAITE = 0; #ifdef USE_16BIT_PMP PMMODEbits.MODE16 = 1; // 16 bit mode #else PMMODEbits.MODE16 = 0; // 8 bit mode #endif PMCONbits.CSF = 0; PMCONbits.PTRDEN = 1; PMCONbits.PTWREN = 1; PMCONbits.PMPEN = 1; // Release from reset RST_LAT_BIT = 1; DelayMs(20); // Setup display #if (DISPLAY_CONTROLLER == SSD1289) ///////////////////////////////////////////////////////// SetReg(0x00, 0x0001); SetReg(0x03, 0xAAAC); SetReg(0x0C, 0x0002); DelayMs(15); SetReg(0x0D, 0x000A); SetReg(0x0E, 0x2D00); SetReg(0x1E, 0x00BC); SetReg(0x01, 0x1A0C); DelayMs(15); #if (DISP_ORIENTATION == 0) SetReg(0x01, 0x2B3F); #else SetReg(0x01, 0x293F); #endif SetReg(0x02, 0x0600); SetReg(0x10, 0x0000); #if (DISP_ORIENTATION == 0) SetReg(0x11, 0x60B0); #else SetReg(0x11, 0x60B8); #endif SetReg(0x05, 0x0000); SetReg(0x06, 0x0000); DelayMs(100); SetReg(0x16, 0xEF1C); SetReg(0x17, 0x0003); SetReg(0x07, 0x0233); SetReg(0x0B, 0x0000); SetReg(0x0F, 0x0000); SetReg(0x41, 0x0000); SetReg(0x42, 0x0000); SetReg(0x48, 0x0000); SetReg(0x49, 0x013F); SetReg(0x44, 0xEF00); SetReg(0x45, 0x0000); SetReg(0x46, 0x013F); SetReg(0x4A, 0x0000); SetReg(0x4B, 0x0000); SetReg(0x30, 0x0707); SetReg(0x31, 0x0704); SetReg(0x32, 0x0204); SetReg(0x33, 0x0502); SetReg(0x34, 0x0507); SetReg(0x35, 0x0204); SetReg(0x36, 0x0204); SetReg(0x37, 0x0502); SetReg(0x3A, 0x0302); SetReg(0x3B, 0x1f00); SetReg(0x23, 0x0000); SetReg(0x24, 0x0000); #elif (DISPLAY_CONTROLLER == SSD2119) SetReg(0x0028, 0x0006); // VCOM OTP, page 55-56 of datasheet SetReg(0x0000, 0x0001); // start Oscillator, page 36 of datasheet SetReg(0x0010, 0x0000); // Sleep mode, page 49 of datasheet #if (DISP_ORIENTATION == 0) SetReg(0x0001, 0x72EF); // Driver Output Control, page 36-39 of datasheet #else SetReg(0x0001, 0x32EF); // Driver Output Control, page 36-39 of datasheet #endif SetReg(0x0002, 0x0600); // LCD Driving Waveform Control, page 40-42 of datasheet SetReg(0x0003, 0x6A38); // Power Control 1, page 43-44 of datasheet #if (DISP_ORIENTATION == 0) SetReg(0x0011, 0x6870); // Entry Mode, page 50-52 of datasheet #else SetReg(0x0011, 0x6878); // Entry Mode, page 50-52 of datasheet #endif SetReg(0x000F, 0x0000); // Gate Scan Position, page 49 of datasheet SetReg(0x000B, 0x5308); // Frame Cycle Control, page 45 of datasheet SetReg(0x000C, 0x0003); // Power Control 2, page 47 of datasheet SetReg(0x000D, 0x000A); // Power Control 3, page 48 of datasheet SetReg(0x000E, 0x2E00); // Power Control 4, page 48 of datasheet SetReg(0x001E, 0x00BE); // Power Control 5, page 53 of datasheet SetReg(0x0025, 0x8000); // Frame Frequency Control, page 53 of datasheet SetReg(0x0026, 0x7800); // Analog setting, page 54 of datasheet SetReg(0x004E, 0x0000); // Ram Address Set, page 58 of datasheet SetReg(0x004F, 0x0000); // Ram Address Set, page 58 of datasheet SetReg(0x0012, 0x08D9); // Sleep mode, page 49 of datasheet // Gamma Control (R30h to R3Bh) -- page 56 of datasheet SetReg(0x0030, 0x0000); SetReg(0x0031, 0x0104); SetReg(0x0032, 0x0100); SetReg(0x0033, 0x0305); SetReg(0x0034, 0x0505); SetReg(0x0035, 0x0305); SetReg(0x0036, 0x0707); SetReg(0x0037, 0x0300); SetReg(0x003A, 0x1200); SetReg(0x003B, 0x0800); SetReg(0x0007, 0x0033); // Display Control, page 45 of datasheet #endif DelayMs(50); }
void PCF8583::SecondToggle(void) { SetReg(AlarmControlRegAddr,0x08); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Initialize the device DeviceInit(); // Gamma for CMO 2.8 SetReg(0x46, 0x95); // SetReg(0x47, 0x51); // SetReg(0x48, 0x00); // SetReg(0x49, 0x36); // SetReg(0x4A, 0x11); // SetReg(0x4B, 0x66); // SetReg(0x4C, 0x14); // SetReg(0x4D, 0x77); // SetReg(0x4E, 0x13); // SetReg(0x4F, 0x4C); // SetReg(0x50, 0x46); // SetReg(0x51, 0x46); // // Display SetReg(0x90, 0x7F); // SAP=0111 1111 SetReg(0x01, 0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 #if (DISP_ORIENTATION == 0) SetReg(0x16, 0xC8); // MY=1, MX=1, MV=0, BGR=1 #else SetReg(0x16, 0xA8); // MY=1, MX=0, MV=1, BGR=1 #endif SetReg(0x23, 0x95); // N_DC=1001 0101 SetReg(0x24, 0x95); // P_DC=1001 0101 SetReg(0x25, 0xFF); // I_DC=1111 1111 SetReg(0x27, 0x06); // N_BP=0000 0110 SetReg(0x28, 0x06); // N_FP=0000 0110 SetReg(0x29, 0x06); // P_BP=0000 0110 SetReg(0x2A, 0x06); // P_FP=0000 0110 SetReg(0x2C, 0x06); // I_BP=0000 0110 SetReg(0x2D, 0x06); // I_FP=0000 0110 SetReg(0x3A, 0x01); // N_RTN=0000, N_NW=001 SetReg(0x3B, 0x01); // P_RTN=0000, P_NW=001 SetReg(0x3C, 0xF0); // I_RTN=1111, I_NW=000 SetReg(0x3D, 0x00); // DIV=00 DelayMs(20); SetReg(0x10, 0xA6); // SS=0,GS=0 CSEL=110 // Power Supply Setting SetReg(0x19, 0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz SetReg(0x93, 0x0C); // RADJ=1100, DelayMs(10); SetReg(0x20, 0x40); // BT=0100 SetReg(0x1D, 0x07); // VC1=111 SetReg(0x1E, 0x00); // VC3=000 SetReg(0x1F, 0x04); // VRH=0100 4.12V SetReg(0x44, 0x4D); // VCM=101 0000 3.21V SetReg(0x45, 0x11); // VDV=1 0001 -1.19V DelayMs(10); SetReg(0x1C, 0x04); // AP=100 DelayMs(20); SetReg(0x43, 0x80); //set VCOMG=1 DelayMs(5); SetReg(0x1B, 0x18); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); SetReg(0x1B, 0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); // Display ON Setting SetReg(0x26, 0x04); // GON=0, DTE=0, D=01 DelayMs(40); SetReg(0x26, 0x24); // GON=1, DTE=0, D=01 SetReg(0x26, 0x2C); // GON=1, DTE=0, D=11 DelayMs(40); SetReg(0x26, 0x3C); // GON=1, DTE=1, D=11 SetReg(0x35, 0x38); // EQS=38h SetReg(0x36, 0x78); // EQP=78h SetReg(0x3E, 0x38); // SON=38h SetReg(0x40, 0x0F); // GDON=0Fh SetReg(0x41, 0xF0); // GDOFF // Set spulse & rpulse SetReg(0x57, 0x02); // Test mode='1' SetReg(0x56, 0x84); // set Rpulse='1000',spulse='0100' SetReg(0x57, 0x00); // Test mode= '0' #if (DISP_ORIENTATION == 0) SetReg(0x04, 0x00); SetReg(0x05, 0xEF); SetReg(0x08, 0x01); SetReg(0x09, 0x3F); #else SetReg(0x04, 0x01); SetReg(0x05, 0x3F); SetReg(0x08, 0x00); SetReg(0x09, 0xEF); #endif DelayMs(20); /* RST_LAT_BIT=0; delayms(20); RST_LAT_BIT=1; delayms(100); */ /* //WriteDirect(CMD_MODE,0x46); // WriteDirect(DATA_MODE,0x00D2); SetReg(0x46,0x00D2); // WriteDirect(CMD_MODE,0x47); // WriteDirect(DATA_MODE,0x0050); SetReg(0x47,0x0050); // WriteDirect(CMD_MODE,0x48); // WriteDirect(DATA_MODE,0x0007); SetReg(0x48,0x0007); // WriteDirect(CMD_MODE,0x49); // WriteDirect(DATA_MODE,0x0043); SetReg(0x49,0x0043); // WriteDirect(CMD_MODE,0x4A); // WriteDirect(DATA_MODE,0x0044); SetReg(0x4A,0x0044); // WriteDirect(CMD_MODE,0x4B); // WriteDirect(DATA_MODE,0x0077); SetReg(0x4B,0x0077); // WriteDirect(CMD_MODE,0x4C); // WriteDirect(DATA_MODE,0x0066); SetReg(0x4C,0x0066); // WriteDirect(CMD_MODE,0x4D); // WriteDirect(DATA_MODE,0x0016); SetReg(0x4D,0x0016); // WriteDirect(CMD_MODE,0x4E); // WriteDirect(DATA_MODE,0x0012); SetReg(0x4E,0x0012); // WriteDirect(CMD_MODE,0x4F); // WriteDirect(DATA_MODE,0x004C); SetReg(0x4F,0x004C); // WriteDirect(CMD_MODE,0x50); // WriteDirect(DATA_MODE,0x0046); SetReg(0x50,0x0046); // WriteDirect(CMD_MODE,0x51); // WriteDirect(DATA_MODE,0x0044); SetReg(0x51,0x0044); //240*320window setting SetReg(0x0002,0x0000); // Column address start2 SetReg(0x0003,0x0000); // Column address start1 SetReg(0x0004,0x0000); // Column address end2 SetReg(0x0005,0x00EF); // Column address end1 SetReg(0x0006,0x0000); // Row address start2 SetReg(0x0007,0x0000); // Row address start1 SetReg(0x0008,0x0001); // Row address end2 SetReg(0x0009,0x003F); // Row address end1 //WriteDirect(CMD_MODE,0x22); //Display setting // WriteDirect(CMD_MODE,0x01); // WriteDirect(DATA_MODE,0x0006); //0x0006 SetReg(0x01,0x0006); // WriteDirect(CMD_MODE,0x16); // WriteDirect(DATA_MODE,0x00A8);//0X48//0x00C8//0x0068//0x0008//0x00A8 SetReg(0x16,0x00A8); // WriteDirect(CMD_MODE,0x23); // WriteDirect(DATA_MODE,0x0095); SetReg(0x23,0x0095); // WriteDirect(CMD_MODE,0x24); // WriteDirect(DATA_MODE,0x0095); SetReg(0x24,0x0095); // WriteDirect(CMD_MODE,0x25); // WriteDirect(DATA_MODE,0x00FF); SetReg(0x25,0x00FF); // WriteDirect(CMD_MODE,0x27); // WriteDirect(DATA_MODE,0x0002); SetReg(0x27,0x0002); // WriteDirect(CMD_MODE,0x28); // WriteDirect(DATA_MODE,0x0002); SetReg(0x28,0x0002); // WriteDirect(CMD_MODE,0x29); // WriteDirect(DATA_MODE,0x0002); SetReg(0x29,0x0002); // WriteDirect(CMD_MODE,0x2A); // WriteDirect(DATA_MODE,0x0002); SetReg(0x2A,0x0002); // WriteDirect(CMD_MODE,0x2C); // WriteDirect(DATA_MODE,0x0002); SetReg(0x2C,0x0002); // WriteDirect(CMD_MODE,0x2D); // WriteDirect(DATA_MODE,0x0002); SetReg(0x2D,0x0002); // WriteDirect(CMD_MODE,0x3A); // WriteDirect(DATA_MODE,0x0001); SetReg(0x3A,0x0001); // WriteDirect(CMD_MODE,0x3B); // WriteDirect(DATA_MODE,0x0001); SetReg(0x3B,0x0001); // WriteDirect(CMD_MODE,0x3C); // WriteDirect(DATA_MODE,0x00F0); SetReg(0x3C,0x00F0); // WriteDirect(CMD_MODE,0x3D); // WriteDirect(DATA_MODE,0x0000); SetReg(0x3D,0x0000); delay(20); // WriteDirect(CMD_MODE,0x35); // WriteDirect(DATA_MODE,0x0038); SetReg(0x35,0x0038); // WriteDirect(CMD_MODE,0x36); // WriteDirect(DATA_MODE,0x0078); SetReg(0x36,0x0078); // WriteDirect(CMD_MODE,0x3E); // WriteDirect(DATA_MODE,0x0038); SetReg(0x3E,0x0038); // WriteDirect(CMD_MODE,0x40); // WriteDirect(DATA_MODE,0x000F); SetReg(0x40,0x000F); // WriteDirect(CMD_MODE,0x41); // WriteDirect(DATA_MODE,0x00F0); SetReg(0x41,0x00F0); // WriteDirect(CMD_MODE,0x19); // WriteDirect(DATA_MODE,0x0049); SetReg(0x19,0x0049); // WriteDirect(CMD_MODE,0x93); // WriteDirect(DATA_MODE,0x0003); SetReg(0x93,0x0003); delay(10); // WriteDirect(CMD_MODE,0x20); // WriteDirect(DATA_MODE,0x0020); SetReg(0x20,0x0020); // WriteDirect(CMD_MODE,0x1D); // WriteDirect(DATA_MODE,0x0005); SetReg(0x1D,0x0005); delay(10); // WriteDirect(CMD_MODE,0x1E); // WriteDirect(DATA_MODE,0x0006); SetReg(0x1E,0x0006); // WriteDirect(CMD_MODE,0x1F); // WriteDirect(DATA_MODE,0x0008); SetReg(0x1F,0x0008); //VCOM setting // WriteDirect(CMD_MODE,0x44); // WriteDirect(DATA_MODE,0x0040); SetReg(0x44,0x0040); // WriteDirect(CMD_MODE,0x45); // WriteDirect(DATA_MODE,0x0012); SetReg(0x45,0x0012); delay(10); // WriteDirect(CMD_MODE,0x1C); // WriteDirect(DATA_MODE,0x0004); SetReg(0x1C,0x0004); delay(20); // WriteDirect(CMD_MODE,0x43); // WriteDirect(DATA_MODE,0x0080); SetReg(0x43,0x0080); delay(5); // WriteDirect(CMD_MODE,0x1B); // WriteDirect(DATA_MODE,0x0008);//0X00,0X08 SetReg(0x1B,0x0008); delay(40); // WriteDirect(CMD_MODE,0x1B); // WriteDirect(DATA_MODE,0x0010);//0X00,0X10 SetReg(0x1B,0x0010); delay(40); // WriteDirect(CMD_MODE,0x43); // WriteDirect(DATA_MODE,0x0080); SetReg(0x43,0x0080); delay(10); //Display ON setting // WriteDirect(CMD_MODE,0x90); // WriteDirect(DATA_MODE,0x007F); SetReg(0x90,0x007F); // WriteDirect(CMD_MODE,0x26); // WriteDirect(DATA_MODE,0x0004); SetReg(0x26,0x0004); delay(40); // WriteDirect(CMD_MODE,0x26); // WriteDirect(DATA_MODE,0x0024); SetReg(0x26,0x0024); delay(40); // WriteDirect(CMD_MODE,0x26); // WriteDirect(DATA_MODE,0x002C); SetReg(0x26,0x002C); delay(40); // WriteDirect(CMD_MODE,0x26); // WriteDirect(DATA_MODE,0x003C); SetReg(0x26,0x003C); //Set internal VDDD voltage // WriteDirect(CMD_MODE,0x57); // WriteDirect(DATA_MODE,0x0002); SetReg(0x57,0x0002); // WriteDirect(CMD_MODE,0x55); // WriteDirect(DATA_MODE,0x0000); SetReg(0x55,0x0000); // WriteDirect(CMD_MODE,0x57); // WriteDirect(DATA_MODE,0x0000); SetReg(0x57,0x0000); */ /* // Gamma for CMO 3.2¡± SetReg(0x0046,0x00A4); SetReg(0x0047,0x0053); SetReg(0x0048,0x0000); SetReg(0x0049,0x0044); SetReg(0x004A,0x0004); SetReg(0x004B,0x0067); SetReg(0x004C,0x0033); SetReg(0x004D,0x0077); SetReg(0x004E,0x0012); SetReg(0x004F,0x004C); SetReg(0x0050,0x0046); SetReg(0x0051,0x0044); //240x320 window setting //SetReg(0x001a,0x0001); SetReg(0x0002,0x0000); // Column address start2 SetReg(0x0003,0x0000); // Column address start1 SetReg(0x0004,0x0000); // Column address end2 SetReg(0x0005,0x00EF); // Column address end1 SetReg(0x0006,0x0000); // Row address start2 SetReg(0x0007,0x0000); // Row address start1 SetReg(0x0008,0x0001); // Row address end2 SetReg(0x0009,0x003F); // Row address end1 // Display Setting SetReg(0x0001,0x0006); // IDMON=0, INVON=1, NORON=1, PTLON=0 SetReg(0x0016,0x00c8); // MY=0, MX=0, MV=0, ML=1, BGR=0, TEON=0 SetReg(0x0038,0x0000); // RGB_EN=0, use MPU Interface SetReg(0x0023,0x0095); // N_DC=1001 0101 SetReg(0x0024,0x0095); // PI_DC=1001 0101 SetReg(0x0025,0x00FF); // I_DC=1111 1111 SetReg(0x0027,0x0002); // N_BP=0000 0010 SetReg(0x0028,0x0002); // N_FP=0000 0010 SetReg(0x0029,0x0002); // PI_BP=0000 0010 SetReg(0x002A,0x0002); // PI_FP=0000 0010 SetReg(0x002C,0x0002); // I_BP=0000 0010 SetReg(0x002D,0x0002); // I_FP=0000 0010 SetReg(0x003A,0x0001); // N_RTN=0000, N_NW=001 SetReg(0x003B,0x0000); // PI_RTN=0000, PI_NW=000 SetReg(0x003C,0x00F0); // I_RTN=1111, I_NW=000 SetReg(0x003D,0x0000); // DIV=00 delayms(20); SetReg(0x0035,0x0038); // EQS=38h SetReg(0x0036,0x0078); // EQP=78h SetReg(0x003E,0x0038); // SON=38h SetReg(0x0040,0x000F); // GDON=0Fh SetReg(0x0041,0x00F0); // GDOFF // Power Supply Setting SetReg(0x0019,0x0049); // CADJ=0100, CUADJ=100(FR:60Hz),, OSD_EN=1 SetReg(0x0093,0x000F); // RADJ=1111, 100% delayms(10); SetReg(0x0020,0x0040); // BT=0100 SetReg(0x001D,0x0007); // VC1=111 SetReg(0x001E,0x0000); // VC3=000 SetReg(0x001F,0x0004); // VRH=0100 // VCOM Setting for CMO 3.2¡± Panel SetReg(0x0044,0x004D); // VCM=100 1101 SetReg(0x0045,0x0011); // VDV=1 0001 delayms(10); SetReg(0x001C,0x0004); // AP=100 delayms(20); SetReg(0x001B,0x0018); // GASENB=0, PON=1, DK=1, XDK=0, VLCD_TRI=0, STB=0 delayms(40); SetReg(0x001B,0x0010); // GASENB=0, PON=1, DK=0, XDK=0, VLCD_TRI=0, STB=0 delayms(40); SetReg(0x0043,0x0080); //Set VCOMG=1 delayms(100); // Display ON Setting SetReg(0x0090,0x007F); // SAP=0111 1111 SetReg(0x0026,0x0004); //GON=0, DTE=0, D=01 delayms(40); SetReg(0x0026,0x0024); //GON=1, DTE=0, D=01 SetReg(0x0026,0x002C); //GON=1, DTE=0, D=11 delayms(40); SetReg(0x0026,0x003C); //GON=1, DTE=1, D=11 // Internal register setting SetReg(0x0057,0x0002); //Test_Mode Enable SetReg(0x0095,0x0001); // Set Display clock and Pumping clock to synchronize SetReg(0x0057,0x0000); // Test_Mode Disable */ /* // Gamma for CMO 2.4 SetReg(0x0046,0x0094); SetReg(0x0047,0x0041); SetReg(0x0048,0x0000); SetReg(0x0049,0x0033); SetReg(0x004A,0x0023); SetReg(0x004B,0x0045); SetReg(0x004C,0x0044); SetReg(0x004D,0x0077); SetReg(0x004E,0x0012); SetReg(0x004F,0x00CC); SetReg(0x0050,0x0046); SetReg(0x0051,0x0082); //240x320 window setting SetReg(0x0002,0x0000); // Column address start2 SetReg(0x0003,0x0000); // Column address start1 SetReg(0x0004,0x0000); // Column address end2 SetReg(0x0005,0x00EF); // Column address end1 SetReg(0x0006,0x0000); // Row address start2 SetReg(0x0007,0x0000); // Row address start1 SetReg(0x0008,0x0001); // Row address end2 SetReg(0x0009,0x003F); // Row address end1 // Display Setting SetReg(0x0001,0x0006); // IDMON=0, INVON=1, NORON=1, PTLON=0 SetReg(0x0016,0x0008); // MY=0, MX=0, MV=0, ML=1, BGR=0, TEON=0 SetReg(0x0070,0x00C6); // SS=1, GS=1, MV=0, ML=1, BGR=0, TEON=0 SetReg(0x0038,0x0000); // RGB_EN=0, use MPU Interface SetReg(0x0023,0x0095); // N_DC=1001 0101 SetReg(0x0024,0x0095); // PI_DC=1001 0101 SetReg(0x0025,0x00FF); // I_DC=1111 1111 SetReg(0x0027,0x0002); // N_BP=0000 0010 SetReg(0x0028,0x0002); // N_FP=0000 0010 SetReg(0x0029,0x0002); // PI_BP=0000 0010 SetReg(0x002A,0x0002); // PI_FP=0000 0010 SetReg(0x002C,0x0002); // I_BP=0000 0010 SetReg(0x002D,0x0002); // I_FP=0000 0010 SetReg(0x003A,0x0001); // N_RTN=0000, N_NW=001 SetReg(0x003B,0x0000); // PI_RTN=0000, PI_NW=000 SetReg(0x003C,0x00F0); // I_RTN=1111, I_NW=000 SetReg(0x003D,0x0000); // DIV=00 delayms(20); SetReg(0x0035,0x0038); // EQS=38h SetReg(0x0036,0x0078); // EQP=78h SetReg(0x003E,0x0038); // SON=38h SetReg(0x0040,0x000F); // GDON=0Fh SetReg(0x0041,0x00F0); // GDOFF // Power Supply Setting SetReg(0x0019,0x006B); // CADJ=0100, CUADJ=100(FR:60Hz),, OSD_EN=1 SetReg(0x0093,0x000A); // RADJ=1111, 100% delayms(10); SetReg(0x0020,0x0040); // BT=0100 SetReg(0x001D,0x0007); // VC1=111 SetReg(0x001E,0x0000); // VC3=000 SetReg(0x001F,0x0004); // VRH=0100 // VCOM Setting for CMO 2.4¡± Panel SetReg(0x0044,0x003c); // VCM=100 0000 38 SetReg(0x0045,0x0011); // VDV=1 0001 13 delayms(10); SetReg(0x001C,0x0004); // AP=100 delayms(20); SetReg(0x001B,0x0018); // GASENB=0, PON=1, DK=1, XDK=0, VLCD_TRI=0, STB=0 delayms(40); SetReg(0x001B,0x0010); // GASENB=0, PON=1, DK=0, XDK=0, VLCD_TRI=0, STB=0 delayms(40); SetReg(0x0043,0x0080); //Set VCOMG=1 delayms(100); // Display ON Setting SetReg(0x0090,0x007F); // SAP=0111 1111 SetReg(0x0026,0x0004); //GON=0, DTE=0, D=01 delayms(40); SetReg(0x0026,0x0024); //GON=1, DTE=0, D=01 SetReg(0x0026,0x002C); //GON=1, DTE=0, D=11 delayms(40); SetReg(0x0026,0x003C); //GON=1, DTE=1, D=11 // Internal register setting SetReg(0x0057,0x0002); //Test_Mode Enable SetReg(0x0095,0x0001); // Set Display clock and Pumping clock to synchronize SetReg(0x0057,0x0000); // Test_Mode Disable */ /* DeviceSelect(); DeviceSetCommand(); DeviceWrite(0x72); DeviceSetData(); registed=DeviceRead(); DeviceDeselect(); */ }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Initialize the device DriverInterfaceInit(); // Setup display #if defined (GFX_USE_DISPLAY_CONTROLLER_SSD1289) ///////////////////////////////////////////////////////// SetReg(0x00, 0x0001); SetReg(0x03, 0xAAAC); SetReg(0x0C, 0x0002); DelayMs(15); SetReg(0x0D, 0x000A); SetReg(0x0E, 0x2D00); SetReg(0x1E, 0x00BC); SetReg(0x01, 0x1A0C); DelayMs(15); #if (DISP_ORIENTATION == 0) SetReg(0x01, 0x2B3F); #else SetReg(0x01, 0x293F); #endif SetReg(0x02, 0x0600); SetReg(0x10, 0x0000); #if (DISP_ORIENTATION == 0) SetReg(0x11, 0x60B0); #else SetReg(0x11, 0x60B8); #endif SetReg(0x05, 0x0000); SetReg(0x06, 0x0000); DelayMs(100); SetReg(0x16, 0xEF1C); SetReg(0x17, 0x0003); SetReg(0x07, 0x0233); SetReg(0x0B, 0x0000); SetReg(0x0F, 0x0000); SetReg(0x41, 0x0000); SetReg(0x42, 0x0000); SetReg(0x48, 0x0000); SetReg(0x49, 0x013F); SetReg(0x44, 0xEF00); SetReg(0x45, 0x0000); SetReg(0x46, 0x013F); SetReg(0x4A, 0x0000); SetReg(0x4B, 0x0000); SetReg(0x30, 0x0707); SetReg(0x31, 0x0704); SetReg(0x32, 0x0204); SetReg(0x33, 0x0502); SetReg(0x34, 0x0507); SetReg(0x35, 0x0204); SetReg(0x36, 0x0204); SetReg(0x37, 0x0502); SetReg(0x3A, 0x0302); SetReg(0x3B, 0x1f00); SetReg(0x23, 0x0000); SetReg(0x24, 0x0000); #elif defined (GFX_USE_DISPLAY_CONTROLLER_SSD2119) SetReg(0x0028, 0x0006); // VCOM OTP, page 55-56 of datasheet SetReg(0x0000, 0x0001); // start Oscillator, page 36 of datasheet SetReg(0x0010, 0x0000); // Sleep mode, page 49 of datasheet #if (DISP_ORIENTATION == 0) SetReg(0x0001, 0x72EF); // Driver Output Control, page 36-39 of datasheet #else SetReg(0x0001, 0x32EF); // Driver Output Control, page 36-39 of datasheet #endif SetReg(0x0002, 0x0600); // LCD Driving Waveform Control, page 40-42 of datasheet SetReg(0x0003, 0x6A38); // Power Control 1, page 43-44 of datasheet #if (DISP_ORIENTATION == 0) SetReg(0x0011, 0x6870); // Entry Mode, page 50-52 of datasheet #else SetReg(0x0011, 0x6878); // Entry Mode, page 50-52 of datasheet #endif SetReg(0x000F, 0x0000); // Gate Scan Position, page 49 of datasheet SetReg(0x000B, 0x5308); // Frame Cycle Control, page 45 of datasheet SetReg(0x000C, 0x0003); // Power Control 2, page 47 of datasheet SetReg(0x000D, 0x000A); // Power Control 3, page 48 of datasheet SetReg(0x000E, 0x2E00); // Power Control 4, page 48 of datasheet SetReg(0x001E, 0x00BE); // Power Control 5, page 53 of datasheet SetReg(0x0025, 0x8000); // Frame Frequency Control, page 53 of datasheet SetReg(0x0026, 0x7800); // Analog setting, page 54 of datasheet SetReg(0x004E, 0x0000); // Ram Address Set, page 58 of datasheet SetReg(0x004F, 0x0000); // Ram Address Set, page 58 of datasheet SetReg(0x0012, 0x08D9); // Sleep mode, page 49 of datasheet // Gamma Control (R30h to R3Bh) -- page 56 of datasheet SetReg(0x0030, 0x0000); SetReg(0x0031, 0x0104); SetReg(0x0032, 0x0100); SetReg(0x0033, 0x0305); SetReg(0x0034, 0x0505); SetReg(0x0035, 0x0305); SetReg(0x0036, 0x0707); SetReg(0x0037, 0x0300); SetReg(0x003A, 0x1200); SetReg(0x003B, 0x0800); SetReg(0x0007, 0x0033); // Display Control, page 45 of datasheet #endif DelayMs(50); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void){ // Disable FLASH CS_FLASH_LAT_BIT = 1; // Set FLASH CS pin as output CS_FLASH_TRIS_BIT = 0; // Hold in reset RST_LAT_BIT = 0; // Set reset pin as output RST_TRIS_BIT = 0; // Enable data access RS_LAT_BIT = 1; // Set RS pin as output RS_TRIS_BIT = 0; // Disable LCD CS_LAT_BIT = 1; // Set LCD CS pin as output CS_TRIS_BIT = 0; DelayMs(500); #if (GRAPHICS_PICTAIL_VERSION == 2) // Power on LCD POWERON_LAT_BIT = 0; POWERON_TRIS_BIT = 0; #endif DelayMs(200); // PMP setup PMMODE = 0; PMAEN = 0; PMCON = 0; PMMODEbits.MODE = 2; // Master 2 PMMODEbits.WAITB = 0; PMMODEbits.WAITM = 1; PMMODEbits.WAITE = 0; PMCONbits.CSF = 0; PMCONbits.PTRDEN = 1; PMCONbits.PTWREN = 1; PMCONbits.PMPEN = 1; // Release from reset RST_LAT_BIT = 1; DelayMs(20); // Synchronization after reset CS_LAT_BIT = 0; WriteData(0,0); WriteData(0,0); CS_LAT_BIT = 1; // Setup display SetReg(0x10,0x0628); SetReg(0x12,0x0006); SetReg(0x13,0x0A32); SetReg(0x11,0x0040); SetReg(0x15,0x0050); SetReg(0x12,0x0016); DelayMs(15); SetReg(0x10,0x5660); DelayMs(15); SetReg(0x13,0x2A4E); SetReg(0x01,0x0100); SetReg(0x02,0x0300); #ifdef USE_PORTRAIT SetReg(0x03,0x1030); #else SetReg(0x03,0x1038); #endif SetReg(0x08,0x0202); SetReg(0x0A,0x0000); SetReg(0x30,0x0000); SetReg(0x31,0x0402); SetReg(0x32,0x0106); SetReg(0x33,0x0700); SetReg(0x34,0x0104); SetReg(0x35,0x0301); SetReg(0x36,0x0707); SetReg(0x37,0x0305); SetReg(0x38,0x0208); SetReg(0x39,0x0F0B); DelayMs(15); SetReg(0x41,0x0002); SetReg(0x60,0x2700); SetReg(0x61,0x0001); SetReg(0x90,0x0119); SetReg(0x92,0x010A); SetReg(0x93,0x0004); SetReg(0xA0,0x0100); SetReg(0x07,0x0001); DelayMs(15); SetReg(0x07,0x0021); DelayMs(15); SetReg(0x07,0x0023); DelayMs(15); SetReg(0x07,0x0033); DelayMs(15); SetReg(0x07,0x0133); DelayMs(15); SetReg(0xA0,0x0000); DelayMs(20); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void){ // Disable FLASH CS_FLASH_LAT_BIT = 1; // Set FLASH CS pin as output CS_FLASH_TRIS_BIT = 0; // Hold in reset RST_LAT_BIT = 0; // Set reset pin as output RST_TRIS_BIT = 0; // Enable data access RS_LAT_BIT = 1; // Set RS pin as output RS_TRIS_BIT = 0; // Disable LCD CS_LAT_BIT = 1; // Set LCD CS pin as output CS_TRIS_BIT = 0; DelayMs(200); // PMP setup PMMODE = 0; PMAEN = 0; PMCON = 0; PMMODEbits.MODE = 2; // Master 2 PMMODEbits.WAITB = 0; PMMODEbits.WAITM = 1; PMMODEbits.WAITE = 0; PMCONbits.CSF = 0; PMCONbits.PTRDEN = 1; PMCONbits.PTWREN = 1; PMCONbits.PMPEN = 1; // Release from reset RST_LAT_BIT = 1; // Setup display SetReg(0x00, 0x0000); SetReg(0x01, 0x0000); SetReg(0x02, 0x0700); #ifdef USE_PORTRAIT SetReg(0x03, 0x1010); #else SetReg(0x03, 0x1028); #endif SetReg(0x04, 0x0000); SetReg(0x08, 0x0207); SetReg(0x09, 0x0000); SetReg(0x0a, 0x0000); SetReg(0x0c, 0x0000); SetReg(0x0d, 0x0000); SetReg(0x0f, 0x0000); SetReg(0x07, 0x0101); SetReg(0x10, 0x12b0); SetReg(0x11, 0x0007); SetReg(0x17, 0x0001); SetReg(0x12, 0x01bb); SetReg(0x13, 0x1300); SetReg(0x29, 0x0010); SetReg(0x30, 0x0100); SetReg(0x31, 0x0c19); SetReg(0x32, 0x111e); SetReg(0x33, 0x3819); SetReg(0x34, 0x350b); SetReg(0x35, 0x0e08); SetReg(0x36, 0x0d07); SetReg(0x37, 0x0318); SetReg(0x38, 0x0705); SetReg(0x39, 0x0303); SetReg(0x3a, 0x0905); SetReg(0x3b, 0x0801); SetReg(0x3c, 0x030e); SetReg(0x3d, 0x050d); SetReg(0x3e, 0x0106); SetReg(0x3f, 0x0408); SetReg(0x50, 0x0000); SetReg(0x51, 0x00ef); SetReg(0x52, 0x0000); SetReg(0x53, 0x013f); SetReg(0x60, 0xa700); SetReg(0x61, 0x0001); SetReg(0x6a, 0x0000); SetReg(0x80, 0x0000); SetReg(0x81, 0x0000); SetReg(0x82, 0x0000); SetReg(0x83, 0x0000); SetReg(0x84, 0x0000); SetReg(0x85, 0x0000); SetReg(0x90, 0x0010); SetReg(0x92, 0x0000); SetReg(0x93, 0x0103); SetReg(0x95, 0x0110); SetReg(0x97, 0x0000); SetReg(0x98, 0x0000); SetReg(0xf0, 0x5408); SetReg(0xf3, 0x0010); SetReg(0xf4, 0x001f); SetReg(0xf0, 0x0000); SetReg(0x07, 0x0133); DelayMs(20); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { BYTE bReg; RST_LAT_BIT = 0; // hold in reset by default RST_TRIS_BIT = 0; // enable RESET line A0_TRIS_BIT = 0; // enable A0 line for byte access A17_TRIS_BIT = 0; // enable A17 line RS_TRIS_BIT = 0; // enable RS line CS_LAT_BIT = 1; // SSD1906 is not selected by default CS_TRIS_BIT = 0; // enable 1906 CS line // PMP setup PMMODE = 0; PMAEN = 0; PMCON = 0; PMMODEbits.MODE = 2; // Intel 80 master interface #ifdef __PIC32MX PMMODEbits.WAITB = 3; PMMODEbits.WAITM = 13; PMMODEbits.WAITE = 3; PMMODEbits.INCM = 0; // auto increment address #else PMMODEbits.WAITB = 1; PMMODEbits.WAITM = 5; PMMODEbits.WAITE = 1; PMMODEbits.INCM = 1; // auto increment address #endif #ifdef __PIC32MX PMMODEbits.MODE16 = 0; // 16 bit data are multiplexed #else PMMODEbits.MODE16 = 1; // 16 bit data are multiplexed #endif PMAENbits.PTEN0 = 1; // enable low address latch PMAENbits.PTEN1 = 1; // enable high address latch #ifndef __PIC32MX PMCONbits.PTBEEN = 1; // enable data latch line #endif PMCONbits.ADRMUX = 2; // address is multiplexed on data bus PMCONbits.CSF = 0; PMCONbits.ALP = 1; // set address latch control polarity PMCONbits.PTRDEN = 1; // enable RD line PMCONbits.PTWREN = 1; // enable WR line PMCONbits.PMPEN = 1; // enable PMP DelayMs(40); RST_LAT_BIT = 1; // release from reset DelayMs(20); ///////////////////////////////////////////////////////////////////// // Clock and Panel Configuration // For SSD1906 SCKI input frequency 25MHz pixel clock is 6.25MHz. // TFT display with 18 bit RGB parallel interface. ///////////////////////////////////////////////////////////////////// SetReg(REG_MEMCLK_CONFIG, 0x00); // Reg 4h SetReg(REG_PCLK_CONFIG, 0x32); // Reg 5h SetReg(REG_PANEL_TYPE, 0x61); // Reg 10h ///////////////////////////////////////////////////////////////////// // Horizontal total HT (reg 12h) ///////////////////////////////////////////////////////////////////// #define HT (DISP_HOR_PULSE_WIDTH + DISP_HOR_BACK_PORCH + DISP_HOR_FRONT_PORCH + DISP_HOR_RESOLUTION) SetReg(REG_HORIZ_TOTAL, HT / 8 - 1); ///////////////////////////////////////////////////////////////////// // Horizontal display period HDP (reg 14h) ///////////////////////////////////////////////////////////////////// SetReg(REG_HDP, DISP_HOR_RESOLUTION / 8 - 1); ///////////////////////////////////////////////////////////////////// // Horizontal display period start HDPS (regs 16h, 17h) ///////////////////////////////////////////////////////////////////// #define HDPS (DISP_HOR_PULSE_WIDTH + DISP_HOR_BACK_PORCH) SetReg(REG_HDP_START_POS0, HDPS & 0x00FF); SetReg(REG_HDP_START_POS1, (HDPS >> 8) & 0x00FF); ///////////////////////////////////////////////////////////////////// // Horizontal syncronization pulse width HPW (reg 20h) ///////////////////////////////////////////////////////////////////// SetReg(REG_HSYNC_PULSE_WIDTH, DISP_HOR_PULSE_WIDTH - 1); ///////////////////////////////////////////////////////////////////// // Vertical total VT (regs 18h, 19h) ///////////////////////////////////////////////////////////////////// #define VT (DISP_VER_PULSE_WIDTH + DISP_VER_BACK_PORCH + DISP_VER_FRONT_PORCH + DISP_VER_RESOLUTION) SetReg(REG_VERT_TOTAL0, VT & 0x00FF); SetReg(REG_VERT_TOTAL1, (VT >> 8) & 0x00FF); ///////////////////////////////////////////////////////////////////// // Vertical display period VDP (regs 1ch, 1dh) ///////////////////////////////////////////////////////////////////// #define VDP (DISP_VER_RESOLUTION - 1) SetReg(REG_VDP0, VDP & 0x00FF); SetReg(REG_VDP1, (VDP >> 8) & 0x00FF); ///////////////////////////////////////////////////////////////////// // Vertical display period start VDPS (regs 1eh, 1fh) ///////////////////////////////////////////////////////////////////// #define VDPS (DISP_VER_PULSE_WIDTH + DISP_VER_BACK_PORCH) SetReg(REG_VDP_START_POS0, VDPS & 0x00FF); SetReg(REG_VDP_START_POS1, (VDPS >> 8) & 0x00FF); ///////////////////////////////////////////////////////////////////// // Vertical syncronization pulse width VPW (reg 24h) ///////////////////////////////////////////////////////////////////// SetReg(REG_VSYNC_PULSE_WIDTH, DISP_VER_PULSE_WIDTH - 1); ///////////////////////////////////////////////////////////////////// // ROTATION MODE #if (DISP_ORIENTATION == 0) #define WIN_START_ADDR 0ul #define ROTATION 0 #elif (DISP_ORIENTATION == 90) #define WIN_START_ADDR (((DWORD) GetMaxX() + 1) / 2 - 1) #define ROTATION 1 #elif (DISP_ORIENTATION == 180) #define WIN_START_ADDR ((((DWORD) GetMaxX() + 1) * (GetMaxY() + 1)) / 2 - 1) #define ROTATION 2 #elif (DISP_ORIENTATION == 270) #define WIN_START_ADDR ((((DWORD) GetMaxX() + 1) * GetMaxY()) / 2) #define ROTATION 3 #endif ///////////////////////////////////////////////////////////////////// // Special Effects Register (reg 71h) ///////////////////////////////////////////////////////////////////// SetReg(REG_SPECIAL_EFFECTS, 0x40 | ROTATION); ///////////////////////////////////////////////////////////////////// // Main Window Display Start Address (regs 74h, 75h, 76h) ///////////////////////////////////////////////////////////////////// SetReg(REG_MAIN_WIN_DISP_START_ADDR0, WIN_START_ADDR & 0x00FF); SetReg(REG_MAIN_WIN_DISP_START_ADDR1, (WIN_START_ADDR >> 8) & 0x00FF); SetReg(REG_MAIN_WIN_DISP_START_ADDR2, (WIN_START_ADDR >> 16) & 0x00FF); ///////////////////////////////////////////////////////////////////// // Main Window Display Offset (regs 78h, 79h) ///////////////////////////////////////////////////////////////////// #define WIN_OFFSET ((GetMaxX() + 1) / 2) SetReg(REG_MAIN_WIN_ADDR_OFFSET0, WIN_OFFSET & 0x00FF); SetReg(REG_MAIN_WIN_ADDR_OFFSET1, (WIN_OFFSET >> 8) & 0x00FF); ///////////////////////////////////////////////////////////////////// // Display Mode Register (reg 70h) ///////////////////////////////////////////////////////////////////// SetReg(REG_DISPLAY_MODE, 0x04); // 16 BPP, enable RAM content to screen ///////////////////////////////////////////////////////////////////// // Power Saving Configuration Register (reg a0h) ///////////////////////////////////////////////////////////////////// SetReg(REG_POWER_SAVE_CONFIG, 0x00); // wake up ///////////////////////////////////////////////////////////////////// // GPIO Status/Control Register (reg adh) // GPO must be connected to POWER_ON input of the LCD ///////////////////////////////////////////////////////////////////// SetReg(REG_GPIO_STATUS_CONTROL1, 0x80); // set GPO high to turn on LCD panel ///////////////////////////////////////////////////////////////////// // Use the timing controller if the display panel used requires it ///////////////////////////////////////////////////////////////////// TCON_Init(); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Disable FLASH CS_FLASH_LAT_BIT = 1; // Set FLASH CS pin as output CS_FLASH_TRIS_BIT = 0; // Hold in reset RST_LAT_BIT = 0; // Set reset pin as output RST_TRIS_BIT = 0; // Enable data access RS_LAT_BIT = 1; // Set RS pin as output RS_TRIS_BIT = 0; // Disable LCD CS_LAT_BIT = 1; // Set LCD CS pin as output CS_TRIS_BIT = 0; DelayMs(500); #if ((GRAPHICS_HARDWARE_PLATFORM == GFX_PICTAIL_V2) || (GRAPHICS_HARDWARE_PLATFORM == GFX_PICTAIL_V250)) // Power on LCD POWERON_LAT_BIT = 0; POWERON_TRIS_BIT = 0; #endif DelayMs(200); // PMP setup PMMODE = 0; PMAEN = 0; PMCON = 0; PMMODEbits.MODE = 2; // Master 2 PMMODEbits.WAITB = 0; #if defined(__dsPIC33F__) || defined(__PIC24H__) PMMODEbits.WAITM = 2; #else PMMODEbits.WAITM = 1; #endif PMMODEbits.WAITE = 0; PMCONbits.CSF = 0; PMCONbits.PTRDEN = 1; PMCONbits.PTWREN = 1; #ifdef USE_16BIT_PMP PMMODEbits.MODE16 = 1; // 16 bit mode #else PMMODEbits.MODE16 = 0; // 8 bit mode #endif PMCONbits.PMPEN = 1; // Release from reset RST_LAT_BIT = 1; DelayMs(20); #if (DISPLAY_CONTROLLER == LGDP4531) ///////////////////////////////////////////////////////// // Synchronization after reset CS_LAT_BIT = 0; WriteData(0); WriteData(0); CS_LAT_BIT = 1; // Setup display SetReg(0x0010, 0x0628); SetReg(0x0012, 0x0006); SetReg(0x0013, 0x0A32); SetReg(0x0011, 0x0040); SetReg(0x0015, 0x0050); SetReg(0x0012, 0x0016); DelayMs(15); SetReg(0x0010, 0x5660); DelayMs(15); SetReg(0x0013, 0x2A4E); SetReg(0x0001, 0x0100); SetReg(0x0002, 0x0300); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); #else SetReg(0x0003, 0x1038); #endif SetReg(0x0008, 0x0202); SetReg(0x000A, 0x0000); SetReg(0x0030, 0x0000); SetReg(0x0031, 0x0402); SetReg(0x0032, 0x0106); SetReg(0x0033, 0x0700); SetReg(0x0034, 0x0104); SetReg(0x0035, 0x0301); SetReg(0x0036, 0x0707); SetReg(0x0037, 0x0305); SetReg(0x0038, 0x0208); SetReg(0x0039, 0x0F0B); DelayMs(15); SetReg(0x0041, 0x0002); SetReg(0x0060, 0x2700); SetReg(0x0061, 0x0001); SetReg(0x0090, 0x0119); SetReg(0x0092, 0x010A); SetReg(0x0093, 0x0004); SetReg(0x00A0, 0x0100); SetReg(0x0007, 0x0001); DelayMs(15); SetReg(0x0007, 0x0021); DelayMs(15); SetReg(0x0007, 0x0023); DelayMs(15); SetReg(0x0007, 0x0033); DelayMs(15); SetReg(0x0007, 0x0133); DelayMs(15); SetReg(0x00A0, 0x0000); DelayMs(20); ///////////////////////////////////////////////////////// #elif (DISPLAY_CONTROLLER == R61505) // Setup display SetReg(0x0000, 0x0000); SetReg(0x0007, 0x0001); DelayMs(5); SetReg(0x0017, 0x0001); DelayMs(5); SetReg(0x0010, 0x17b0); SetReg(0x0011, 0x0007); SetReg(0x0012, 0x011a); SetReg(0x0013, 0x0f00); SetReg(0x0015, 0x0000); SetReg(0x0029, 0x0009); SetReg(0x00fd, 0x0000); DelayMs(5); SetReg(0x0012, 0x013a); DelayMs(50); SetReg(0x0001, 0x0100); SetReg(0x0002, 0x0700); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); #else SetReg(0x0003, 0x1038); #endif SetReg(0x0008, 0x0808); SetReg(0x0009, 0x0000); SetReg(0x000a, 0x0000); SetReg(0x000c, 0x0000); SetReg(0x000d, 0x0000); SetReg(0x0030, 0x0000); SetReg(0x0031, 0x0000); SetReg(0x0032, 0x0000); SetReg(0x0033, 0x0000); SetReg(0x0034, 0x0000); SetReg(0x0035, 0x0000); SetReg(0x0036, 0x0000); SetReg(0x0037, 0x0707); SetReg(0x0038, 0x0707); SetReg(0x0039, 0x0707); SetReg(0x003a, 0x0303); SetReg(0x003b, 0x0303); SetReg(0x003c, 0x0707); SetReg(0x003d, 0x0808); SetReg(0x0050, 0x0000); SetReg(0x0051, 0x00ef); SetReg(0x0052, 0x0000); SetReg(0x0053, 0x013f); SetReg(0x0060, 0x2700); SetReg(0x0061, 0x0001); SetReg(0x006a, 0x0000); SetReg(0x0090, 0x0010); SetReg(0x0092, 0x0000); SetReg(0x0093, 0x0000); SetReg(0x0007, 0x0021); DelayMs(1); SetReg(0x0007, 0x0061); DelayMs(50); SetReg(0x0007, 0x0173); SetReg(0x0020, 0x0000); SetReg(0x0021, 0x0000); SetReg(0x0022, 0x0000); SetReg(0x0030, 0x0707); SetReg(0x0031, 0x0407); SetReg(0x0032, 0x0203); SetReg(0x0033, 0x0303); SetReg(0x0034, 0x0303); SetReg(0x0035, 0x0202); SetReg(0x0036, 0x001f); SetReg(0x0037, 0x0707); SetReg(0x0038, 0x0407); SetReg(0x0039, 0x0203); SetReg(0x003a, 0x0303); SetReg(0x003b, 0x0303); SetReg(0x003c, 0x0202); SetReg(0x003d, 0x001f); SetReg(0x0020, 0x0000); SetReg(0x0021, 0x0000); ///////////////////////////////////////////////////////// #elif (DISPLAY_CONTROLLER == S6D0129) || (DISPLAY_CONTROLLER == S6D0139) // Setup display SetReg(0x0000, 0x0001); SetReg(0x0011, 0x1a00); SetReg(0x0014, 0x2020); SetReg(0x0010, 0x0900); SetReg(0x0013, 0x0040); SetReg(0x0013, 0x0060); SetReg(0x0013, 0x0070); SetReg(0x0011, 0x1a04); SetReg(0x0010, 0x2f00); SetReg(0x0001, 0x0127); SetReg(0x0002, 0x0700); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); #else SetReg(0x0003, 0x1038); #endif SetReg(0x0007, 0x0000); SetReg(0x0008, 0x0808); SetReg(0x0009, 0x0000); SetReg(0x000b, 0x0000); SetReg(0x000c, 0x0000); SetReg(0x0040, 0x0000); SetReg(0x0041, 0x0000); SetReg(0x0042, 0x013f); SetReg(0x0043, 0x0000); SetReg(0x0044, 0x00ef); SetReg(0x0045, 0x0000); SetReg(0x0046, 0xef00); SetReg(0x0047, 0x013f); SetReg(0x0048, 0x0000); SetReg(0x0007, 0x0014); SetReg(0x0007, 0x0016); SetReg(0x0007, 0x0017); SetReg(0x0020, 0x0000); SetReg(0x0021, 0x0000); SetReg(0x0022, 0x0000); ///////////////////////////////////////////////////////// #elif (DISPLAY_CONTROLLER == SPFD5408) // Setup display SetReg(0x0000, 0x0000); SetReg(0x0001, 0x0000); SetReg(0x0002, 0x0700); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1010); #else SetReg(0x0003, 0x1028); #endif SetReg(0x0004, 0x0000); SetReg(0x0008, 0x0207); SetReg(0x0009, 0x0000); SetReg(0x000a, 0x0000); SetReg(0x000c, 0x0000); SetReg(0x000d, 0x0000); SetReg(0x000f, 0x0000); SetReg(0x0007, 0x0101); SetReg(0x0010, 0x12b0); SetReg(0x0011, 0x0007); SetReg(0x0017, 0x0001); SetReg(0x0012, 0x01bb); SetReg(0x0013, 0x1300); SetReg(0x0029, 0x0010); SetReg(0x0030, 0x0100); SetReg(0x0031, 0x0c19); SetReg(0x0032, 0x111e); SetReg(0x0033, 0x3819); SetReg(0x0034, 0x350b); SetReg(0x0035, 0x0e08); SetReg(0x0036, 0x0d07); SetReg(0x0037, 0x0318); SetReg(0x0038, 0x0705); SetReg(0x0039, 0x0303); SetReg(0x003a, 0x0905); SetReg(0x003b, 0x0801); SetReg(0x003c, 0x030e); SetReg(0x003d, 0x050d); SetReg(0x003e, 0x0106); SetReg(0x003f, 0x0408); SetReg(0x0050, 0x0000); SetReg(0x0051, 0x00ef); SetReg(0x0052, 0x0000); SetReg(0x0053, 0x013f); SetReg(0x0060, 0xa700); SetReg(0x0061, 0x0001); SetReg(0x006a, 0x0000); SetReg(0x0080, 0x0000); SetReg(0x0081, 0x0000); SetReg(0x0082, 0x0000); SetReg(0x0083, 0x0000); SetReg(0x0084, 0x0000); SetReg(0x0085, 0x0000); SetReg(0x0090, 0x0010); SetReg(0x0092, 0x0000); SetReg(0x0093, 0x0103); SetReg(0x0095, 0x0110); SetReg(0x0097, 0x0000); SetReg(0x0098, 0x0000); SetReg(0x00f0, 0x5408); SetReg(0x00f3, 0x0010); SetReg(0x00f4, 0x001f); SetReg(0x00f0, 0x0000); SetReg(0x0007, 0x0133); ///////////////////////////////////////////////////////// #elif (DISPLAY_CONTROLLER == ILI9320) SetReg(0x0000, 0x0001); //start Int. osc DelayMs(15); SetReg(0x0001, 0x0100); //Set SS bit (shift direction of outputs is from S720 to S1) SetReg(0x0002, 0x0700); //select the line inversion #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); //Entry mode(Horizontal : increment,Vertical : increment, AM=0) #else SetReg(0x0003, 0x1038); //Entry mode(Horizontal : increment,Vertical : increment, AM=1) #endif SetReg(0x0004, 0x0000); //Resize control(No resizing) SetReg(0x0008, 0x0202); //front and back porch 2 lines SetReg(0x0009, 0x0000); //select normal scan SetReg(0x000A, 0x0000); //display control 4 SetReg(0x000C, 0x0000); //system interface(2 transfer /pixel), internal sys clock, SetReg(0x000D, 0x0000); //Frame marker position SetReg(0x000F, 0x0000); //selects clk, enable and sync signal polarity, SetReg(0x0010, 0x0000); // SetReg(0x0011, 0x0000); //power control 2 reference voltages = 1:1, SetReg(0x0012, 0x0000); //power control 3 VRH SetReg(0x0013, 0x0000); //power control 4 VCOM amplitude DelayMs(20); SetReg(0x0010, 0x17B0); //power control 1 BT,AP SetReg(0x0011, 0x0137); //power control 2 DC,VC DelayMs(50); SetReg(0x0012, 0x0139); //power control 3 VRH DelayMs(50); SetReg(0x0013, 0x1d00); //power control 4 vcom amplitude SetReg(0x0029, 0x0011); //power control 7 VCOMH DelayMs(50); SetReg(0x0030, 0x0007); SetReg(0x0031, 0x0403); SetReg(0x0032, 0x0404); SetReg(0x0035, 0x0002); SetReg(0x0036, 0x0707); SetReg(0x0037, 0x0606); SetReg(0x0038, 0x0106); SetReg(0x0039, 0x0007); SetReg(0x003c, 0x0700); SetReg(0x003d, 0x0707); SetReg(0x0020, 0x0000); //starting Horizontal GRAM Address SetReg(0x0021, 0x0000); //starting Vertical GRAM Address SetReg(0x0050, 0x0000); //Horizontal GRAM Start Position SetReg(0x0051, 0x00EF); //Horizontal GRAM end Position SetReg(0x0052, 0x0000); //Vertical GRAM Start Position SetReg(0x0053, 0x013F); //Vertical GRAM end Position SetReg(0x0060, 0x2700); //starts scanning from G1, and 320 drive lines SetReg(0x0061, 0x0001); //fixed base display SetReg(0x006a, 0x0000); //no scroll SetReg(0x0090, 0x0010); //set Clocks/Line =16, Internal Operation Clock Frequency=fosc/1, SetReg(0x0092, 0x0000); //set gate output non-overlap period=0 SetReg(0x0093, 0x0003); //set Source Output Position=3 SetReg(0x0095, 0x0110); //RGB interface(Clocks per line period=16 clocks) SetReg(0x0097, 0x0110); //set Gate Non-overlap Period 0 locksc SetReg(0x0098, 0x0110); // SetReg(0x0007, 0x0173); //display On ///////////////////////////////////////////////////////// #elif (DISPLAY_CONTROLLER == R61580) // Synchronization after reset DelayMs(2); SetReg(0x0000, 0x0000); SetReg(0x0000, 0x0000); SetReg(0x0000, 0x0000); SetReg(0x0000, 0x0000); // Setup display SetReg(0x00A4, 0x0001); // CALB=1 DelayMs(2); SetReg(0x0060, 0xA700); // Driver Output Control SetReg(0x0008, 0x0808); // Display Control BP=8, FP=8 SetReg(0x0030, 0x0111); // y control SetReg(0x0031, 0x2410); // y control SetReg(0x0032, 0x0501); // y control SetReg(0x0033, 0x050C); // y control SetReg(0x0034, 0x2211); // y control SetReg(0x0035, 0x0C05); // y control SetReg(0x0036, 0x2105); // y control SetReg(0x0037, 0x1004); // y control SetReg(0x0038, 0x1101); // y control SetReg(0x0039, 0x1122); // y control SetReg(0x0090, 0x0019); // 80Hz SetReg(0x0010, 0x0530); // Power Control SetReg(0x0011, 0x0237); SetReg(0x0012, 0x01BF); SetReg(0x0013, 0x1300); DelayMs(100); SetReg(0x0001, 0x0100); SetReg(0x0002, 0x0200); #if (DISP_ORIENTATION == 0) SetReg(0x0003, 0x1030); #else SetReg(0x0003, 0x1038); #endif SetReg(0x0009, 0x0001); SetReg(0x000A, 0x0008); SetReg(0x000C, 0x0001); SetReg(0x000D, 0xD000); SetReg(0x000E, 0x0030); SetReg(0x000F, 0x0000); SetReg(0x0020, 0x0000); SetReg(0x0021, 0x0000); SetReg(0x0029, 0x0077); SetReg(0x0050, 0x0000); SetReg(0x0051, 0xD0EF); SetReg(0x0052, 0x0000); SetReg(0x0053, 0x013F); SetReg(0x0061, 0x0001); SetReg(0x006A, 0x0000); SetReg(0x0080, 0x0000); SetReg(0x0081, 0x0000); SetReg(0x0082, 0x005F); SetReg(0x0093, 0x0701); SetReg(0x0007, 0x0100); SetReg(0x0022, 0x0000); #else #error Graphics controller is not supported. #endif DelayMs(20); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Hold in reset RST_LAT_BIT = 0; // Set reset pin as output RST_TRIS_BIT = 0; // Enable data access RS_LAT_BIT = 1; // Set RS pin as output RS_TRIS_BIT = 0; // Disable LCD CS_LAT_BIT = 1; // Set LCD CS pin as output CS_TRIS_BIT = 0; // PMP setup PMMODE = 0; PMAEN = 0; PMCON = 0; PMMODEbits.MODE = 2; // Master 2 PMMODEbits.WAITB = 0; #ifdef __PIC32MX PMMODEbits.WAITM = 3; #else PMMODEbits.WAITM = 2; #endif PMMODEbits.WAITE = 0; #ifdef USE_16BIT_PMP PMMODEbits.MODE16 = 1; // 16 bit mode #else PMMODEbits.MODE16 = 0; // 8 bit mode #endif PMCONbits.CSF = 0; PMCONbits.PTRDEN = 1; PMCONbits.PTWREN = 1; PMCONbits.PMPEN = 1; // Release from reset DelayMs(100); RST_LAT_BIT = 1; DelayMs(20); // Gamma for CMO 2.8 SetReg(0x46, 0x95); // SetReg(0x47, 0x51); // SetReg(0x48, 0x00); // SetReg(0x49, 0x36); // SetReg(0x4A, 0x11); // SetReg(0x4B, 0x66); // SetReg(0x4C, 0x14); // SetReg(0x4D, 0x77); // SetReg(0x4E, 0x13); // SetReg(0x4F, 0x4C); // SetReg(0x50, 0x46); // SetReg(0x51, 0x46); // // Display SetReg(0x90, 0x7F); // SAP=0111 1111 SetReg(0x01, 0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 #if (DISP_ORIENTATION == 0) SetReg(0x16, 0xC8); // MY=1, MX=1, MV=0, BGR=1 #else SetReg(0x16, 0xA8); // MY=1, MX=0, MV=1, BGR=1 #endif SetReg(0x23, 0x95); // N_DC=1001 0101 SetReg(0x24, 0x95); // P_DC=1001 0101 SetReg(0x25, 0xFF); // I_DC=1111 1111 SetReg(0x27, 0x06); // N_BP=0000 0110 SetReg(0x28, 0x06); // N_FP=0000 0110 SetReg(0x29, 0x06); // P_BP=0000 0110 SetReg(0x2A, 0x06); // P_FP=0000 0110 SetReg(0x2C, 0x06); // I_BP=0000 0110 SetReg(0x2D, 0x06); // I_FP=0000 0110 SetReg(0x3A, 0x01); // N_RTN=0000, N_NW=001 SetReg(0x3B, 0x01); // P_RTN=0000, P_NW=001 SetReg(0x3C, 0xF0); // I_RTN=1111, I_NW=000 SetReg(0x3D, 0x00); // DIV=00 DelayMs(20); SetReg(0x10, 0xA6); // SS=0,GS=0 CSEL=110 // Power Supply Setting SetReg(0x19, 0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz SetReg(0x93, 0x0C); // RADJ=1100, DelayMs(10); SetReg(0x20, 0x40); // BT=0100 SetReg(0x1D, 0x07); // VC1=111 SetReg(0x1E, 0x00); // VC3=000 SetReg(0x1F, 0x04); // VRH=0100 4.12V SetReg(0x44, 0x4D); // VCM=101 0000 3.21V SetReg(0x45, 0x11); // VDV=1 0001 -1.19V DelayMs(10); SetReg(0x1C, 0x04); // AP=100 DelayMs(20); SetReg(0x43, 0x80); //set VCOMG=1 DelayMs(5); SetReg(0x1B, 0x18); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); SetReg(0x1B, 0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); // Display ON Setting SetReg(0x26, 0x04); // GON=0, DTE=0, D=01 DelayMs(40); SetReg(0x26, 0x24); // GON=1, DTE=0, D=01 SetReg(0x26, 0x2C); // GON=1, DTE=0, D=11 DelayMs(40); SetReg(0x26, 0x3C); // GON=1, DTE=1, D=11 SetReg(0x35, 0x38); // EQS=38h SetReg(0x36, 0x78); // EQP=78h SetReg(0x3E, 0x38); // SON=38h SetReg(0x40, 0x0F); // GDON=0Fh SetReg(0x41, 0xF0); // GDOFF // Set spulse & rpulse SetReg(0x57, 0x02); // Test mode='1' SetReg(0x56, 0x84); // set Rpulse='1000',spulse='0100' SetReg(0x57, 0x00); // Test mode= '0' #if (DISP_ORIENTATION == 0) SetReg(0x04, 0x00); SetReg(0x05, 0xEF); SetReg(0x08, 0x01); SetReg(0x09, 0x3F); #else SetReg(0x04, 0x01); SetReg(0x05, 0x3F); SetReg(0x08, 0x00); SetReg(0x09, 0xEF); #endif DelayMs(20); }
Result HcdChannelSendWaitOne(struct UsbDevice *device, struct UsbPipeAddress *pipe, u8 channel, void* buffer, u32 bufferLength, u32 bufferOffset, struct UsbDeviceRequest *request) { Result result; u32 timeout, tries, globalTries, actualTries; for (globalTries = 0, actualTries = 0; globalTries < 3 && actualTries < 10; globalTries++, actualTries++) { SetReg(&Host->Channel[channel].Interrupt); WriteThroughReg(&Host->Channel[channel].Interrupt); ReadBackReg(&Host->Channel[channel].TransferSize); ReadBackReg(&Host->Channel[channel].SplitControl); HcdTransmitChannel(channel, (u8*)buffer + bufferOffset); timeout = 0; do { if (timeout++ == RequestTimeout) { LOGF("HCD: Request to %s has timed out.\n", UsbGetDescription(device)); device->Error = ConnectionError; return ErrorTimeout; } ReadBackReg(&Host->Channel[channel].Interrupt); if (!Host->Channel[channel].Interrupt.Halt) MicroDelay(10); else break; } while (true); ReadBackReg(&Host->Channel[channel].TransferSize); if (Host->Channel[channel].SplitControl.SplitEnable) { if (Host->Channel[channel].Interrupt.Acknowledgement) { for (tries = 0; tries < 3; tries++) { SetReg(&Host->Channel[channel].Interrupt); WriteThroughReg(&Host->Channel[channel].Interrupt); ReadBackReg(&Host->Channel[channel].SplitControl); Host->Channel[channel].SplitControl.CompleteSplit = true; WriteThroughReg(&Host->Channel[channel].SplitControl); Host->Channel[channel].Characteristic.Enable = true; Host->Channel[channel].Characteristic.Disable = false; WriteThroughReg(&Host->Channel[channel].Characteristic); timeout = 0; do { if (timeout++ == RequestTimeout) { LOGF("HCD: Request split completion to %s has timed out.\n", UsbGetDescription(device)); device->Error = ConnectionError; return ErrorTimeout; } ReadBackReg(&Host->Channel[channel].Interrupt); if (!Host->Channel[channel].Interrupt.Halt) MicroDelay(100); else break; } while (true); if (!Host->Channel[channel].Interrupt.NotYet) break; } if (tries == 3) { MicroDelay(25000); continue; } else if (Host->Channel[channel].Interrupt.NegativeAcknowledgement) { globalTries--; MicroDelay(25000); continue; } else if (Host->Channel[channel].Interrupt.TransactionError) { MicroDelay(25000); continue; } if ((result = HcdChannelInterruptToError(device, Host->Channel[channel].Interrupt, false)) != OK) { LOG_DEBUGF("HCD: Control message to %#x: %02x%02x%02x%02x %02x%02x%02x%02x.\n", *(u32*)pipe, ((u8*)request)[0], ((u8*)request)[1], ((u8*)request)[2], ((u8*)request)[3], ((u8*)request)[4], ((u8*)request)[5], ((u8*)request)[6], ((u8*)request)[7]); LOGF("HCD: Request split completion to %s failed.\n", UsbGetDescription(device)); return result; } } else if (Host->Channel[channel].Interrupt.NegativeAcknowledgement) { globalTries--; MicroDelay(25000); continue; } else if (Host->Channel[channel].Interrupt.TransactionError) { MicroDelay(25000); continue; } } else { if ((result = HcdChannelInterruptToError(device, Host->Channel[channel].Interrupt, !Host->Channel[channel].SplitControl.SplitEnable)) != OK) { LOG_DEBUGF("HCD: Control message to %#x: %02x%02x%02x%02x %02x%02x%02x%02x.\n", *(u32*)pipe, ((u8*)request)[0], ((u8*)request)[1], ((u8*)request)[2], ((u8*)request)[3], ((u8*)request)[4], ((u8*)request)[5], ((u8*)request)[6], ((u8*)request)[7]); LOGF("HCD: Request to %s failed.\n", UsbGetDescription(device)); return ErrorRetry; } } break; } if (globalTries == 3 || actualTries == 10) { LOGF("HCD: Request to %s has failed 3 times.\n", UsbGetDescription(device)); if ((result = HcdChannelInterruptToError(device, Host->Channel[channel].Interrupt, !Host->Channel[channel].SplitControl.SplitEnable)) != OK) { LOG_DEBUGF("HCD: Control message to %#x: %02x%02x%02x%02x %02x%02x%02x%02x.\n", *(u32*)pipe, ((u8*)request)[0], ((u8*)request)[1], ((u8*)request)[2], ((u8*)request)[3], ((u8*)request)[4], ((u8*)request)[5], ((u8*)request)[6], ((u8*)request)[7]); LOGF("HCD: Request to %s failed.\n", UsbGetDescription(device)); return result; } device->Error = ConnectionError; return ErrorTimeout; } return OK; }
/************************************************************************ * Function: void GfxTconSetIO(BYTE mask, BYTE level) * * Overview: This sets the IO specified by mask to the value set by * level. * * Input: mask - specifies the IO to be toggles. * level - specifies the logic where the IO will be set. * * Output: none * ************************************************************************/ void GfxTconSetIO(BYTE mask, BYTE level) { #if defined (GFX_USE_DISPLAY_CONTROLLER_MCHP_DA210) || defined (GFX_USE_DISPLAY_CONTROLLER_DMA) switch(mask) { case BB_CS: (level == 1 ? TCON_CSHigh() : TCON_CSLow()); break; case BB_SCL: (level == 1 ? TCON_CLKHigh() : TCON_CLKLow()); break; case BB_SDO: (level == 1 ? TCON_DataHigh() : TCON_DataLow()); break; case BB_DC: (level == 1 ? TCON_SetData() : TCON_SetCommand()); break; default: break; } Nop(); #elif defined (GFX_USE_DISPLAY_CONTROLLER_SSD1926) static BYTE value = 0xFF; if(level == 0) { value &= ~mask; } else { value |= mask; } SetCtrlBitBangedIO(0xAC, value); #elif defined (GFX_USE_DISPLAY_CONTROLLER_S1D13517) static BYTE temp = 0; switch(mask) { case BB_CS: temp = GetReg(REG6E_GPO_1); if(level == 1) temp |= 0x02; else temp &= 0xFD; SetReg(REG6E_GPO_1,temp); break; case BB_SCL: TCON_SCL_PORT = level; break; case BB_SDO: TCON_SDO_PORT = level; break; case BB_DC: temp = GetReg(REG6E_GPO_1); if(level == 1) temp |= 0x04; else temp &= 0xFB; SetReg(REG6E_GPO_1,temp); break; } Nop(); #else #error "This TCON_SSD1289 is written for SSD1926, S1D13517 and Microchip Graphics Module driver. If you are not using those drivers you may need to re-write this driver and remove this error message." #endif }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Initialize the device DeviceInit(); #if (DISPLAY_CONTROLLER == HX8347A) // Gamma for CMO 2.8 SetReg(0x46, 0x95); // SetReg(0x47, 0x51); // SetReg(0x48, 0x00); // SetReg(0x49, 0x36); // SetReg(0x4A, 0x11); // SetReg(0x4B, 0x66); // SetReg(0x4C, 0x14); // SetReg(0x4D, 0x77); // SetReg(0x4E, 0x13); // SetReg(0x4F, 0x4C); // SetReg(0x50, 0x46); // SetReg(0x51, 0x46); // // Display SetReg(0x90, 0x7F); // SAP=0111 1111 SetReg(0x01, 0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 #if (DISP_ORIENTATION == 0) SetReg(0x16, 0xC8); // MY=1, MX=1, MV=0, BGR=1 #else SetReg(0x16, 0xA8); // MY=1, MX=0, MV=1, BGR=1 #endif SetReg(0x23, 0x95); // N_DC=1001 0101 SetReg(0x24, 0x95); // P_DC=1001 0101 SetReg(0x25, 0xFF); // I_DC=1111 1111 SetReg(0x27, 0x06); // N_BP=0000 0110 SetReg(0x28, 0x06); // N_FP=0000 0110 SetReg(0x29, 0x06); // P_BP=0000 0110 SetReg(0x2A, 0x06); // P_FP=0000 0110 SetReg(0x2C, 0x06); // I_BP=0000 0110 SetReg(0x2D, 0x06); // I_FP=0000 0110 SetReg(0x3A, 0x01); // N_RTN=0000, N_NW=001 SetReg(0x3B, 0x01); // P_RTN=0000, P_NW=001 SetReg(0x3C, 0xF0); // I_RTN=1111, I_NW=000 SetReg(0x3D, 0x00); // DIV=00 DelayMs(20); SetReg(0x10, 0xA6); // SS=0,GS=0 CSEL=110 // Power Supply Setting SetReg(0x19, 0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz SetReg(0x93, 0x0C); // RADJ=1100, DelayMs(10); SetReg(0x20, 0x40); // BT=0100 SetReg(0x1D, 0x07); // VC1=111 SetReg(0x1E, 0x00); // VC3=000 SetReg(0x1F, 0x04); // VRH=0100 4.12V SetReg(0x44, 0x4D); // VCM=101 0000 3.21V SetReg(0x45, 0x11); // VDV=1 0001 -1.19V DelayMs(10); SetReg(0x1C, 0x04); // AP=100 DelayMs(20); SetReg(0x43, 0x80); //set VCOMG=1 DelayMs(5); SetReg(0x1B, 0x18); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); SetReg(0x1B, 0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); // Display ON Setting SetReg(0x26, 0x04); // GON=0, DTE=0, D=01 DelayMs(40); SetReg(0x26, 0x24); // GON=1, DTE=0, D=01 SetReg(0x26, 0x2C); // GON=1, DTE=0, D=11 DelayMs(40); SetReg(0x26, 0x3C); // GON=1, DTE=1, D=11 SetReg(0x35, 0x38); // EQS=38h SetReg(0x36, 0x78); // EQP=78h SetReg(0x3E, 0x38); // SON=38h SetReg(0x40, 0x0F); // GDON=0Fh SetReg(0x41, 0xF0); // GDOFF // Set spulse & rpulse SetReg(0x57, 0x02); // Test mode='1' SetReg(0x56, 0x84); // set Rpulse='1000',spulse='0100' SetReg(0x57, 0x00); // Test mode= '0' #if (DISP_ORIENTATION == 0) SetReg(0x04, 0x00); SetReg(0x05, 0xEF); SetReg(0x08, 0x01); SetReg(0x09, 0x3F); #else SetReg(0x04, 0x01); SetReg(0x05, 0x3F); SetReg(0x08, 0x00); SetReg(0x09, 0xEF); #endif DelayMs(20); #elif (DISPLAY_CONTROLLER == HX8347D) // Driving ability setting SetReg(0xEA,0x00); // PTBA[15:8] SetReg(0xEB,0x20); // PTBA[7:0] SetReg(0xEC,0x0C); // STBA[15:8] SetReg(0xED,0xC4); // STBA[7:0] SetReg(0xE8,0x40); // OPON[7:0] SetReg(0xE9,0x38); // OPON1[7:0] SetReg(0xF1,0x01); // OTPS1B SetReg(0xF2,0x10); // GEN SetReg(0x27,0xA3); // // Gamma 2.8 setting SetReg(0x40,0x00); // SetReg(0x41,0x00); // SetReg(0x42,0x01); // SetReg(0x43,0x13); // SetReg(0x44,0x10); // SetReg(0x45,0x26); // SetReg(0x46,0x08); // SetReg(0x47,0x51); // SetReg(0x48,0x02); // SetReg(0x49,0x12); // SetReg(0x4A,0x18); // SetReg(0x4B,0x19); // SetReg(0x4C,0x14); // SetReg(0x50,0x19); // SetReg(0x51,0x2F); // SetReg(0x52,0x2C); // SetReg(0x53,0x3E); // SetReg(0x54,0x3F); // SetReg(0x55,0x3F); // SetReg(0x56,0x2E); // SetReg(0x57,0x77); // SetReg(0x58,0x0B); // SetReg(0x59,0x06); // SetReg(0x5A,0x07); // SetReg(0x5B,0x0D); // SetReg(0x5C,0x1D); // SetReg(0x5D,0xCC); // // Window setting #if (DISP_ORIENTATION == 0) SetReg(0x04,0x00); SetReg(0x05,0xEF); SetReg(0x08,0x01); SetReg(0x09,0x3F); #else SetReg(0x04,0x01); SetReg(0x05,0x3F); SetReg(0x08,0x00); SetReg(0x09,0xEF); #endif // Display Setting //SetReg(0x01,0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 #if (DISP_ORIENTATION == 0) SetReg(0x16,0x08); // MY=0, MX=0, MV=0, BGR=1 #else SetReg(0x16,0x68); // MY=0, MX=1, MV=1, BGR=1 #endif // Power Voltage Setting SetReg(0x1B,0x1B); // VRH = 4.65 SetReg(0x1A,0x01); // BT SetReg(0x24,0x2F); // VMH SetReg(0x25,0x57); // VML // Vcom offset SetReg(0x23,0x8D); // FLICKER ADJUST // Power ON Setting SetReg(0x18,0x36); // SetReg(0x19,0x01); // SetReg(0x01,0x00); // SetReg(0x1F,0x88); // DelayMs(5); SetReg(0x1F,0x80); // DelayMs(5); SetReg(0x1F,0x90); // DelayMs(5); SetReg(0x1F,0xD0); // DelayMs(5); // 65K Color Selection SetReg(0x17,0x05); // // Set Panel SetReg(0x36,0x00); // // Display ON Setting SetReg(0x28,0x38); // DelayMs( 40); SetReg(0x28,0x3C); // #endif }
void Nu_IsGLRenderer () { SetReg (0, 0); }