// ====================================================================== // dualsim_SetSimEnable // ---------------------------------------------------------------------- /// This function set sim0 or sim1 Enalbe // ====================================================================== // CARD0 CARD1 // RSTREG 1010 0101 // CLKREG 0001 0010 // DATAREG 0001 0010 // ====================================================================== PUBLIC DUALSIM_ERR_T foursim_SetSimEnable_8806(DUALSIM_SIM_CARD_T number) { UINT32 delay; if (number < FOURSIM_SIM_SELECT_CARD_0 && number > FOURSIM_SIM_SELECT_CARD_3) { return DUALSIM_ERR_NO; } // while(hal_SimGetClkStatus() && hal_SimGetClkStopStatus())//wait for clock stop // {;} delay = DS_SETSIMEN_DLY; hal_TimDelay(delay MS_WAITING); if (pmd_SelectSimCard(number)) { delay = DS_SETSIMEN_DLY; hal_TimDelay(delay MS_WAITING); // hal_HstSendEvent(0x70000000); return DUALSIM_ERR_NO; } return DUALSIM_ERR_RESOURCE_BUSY; }
PRIVATE LCDD_ERR_T lcddp_Sleep(VOID) { while (0 == lcdd_MutexGet()) { sxr_Sleep(LCDD_TIME_MUTEX_RETRY); LCDD_TRACE(TSTDOUT, 0, "LCDD: Sleep while another LCD operation in progress. Sleep %d ticks", LCDD_TIME_MUTEX_RETRY); } if (g_lcddInSleep) { lcdd_MutexFree(); return LCDD_ERR_NO; } LCM_WR_CMD_8(0x28); // Display off hal_TimDelay(50 MS_WAITING); LCM_WR_CMD_8(0x10); hal_TimDelay(100 MS_WAITING); LCDD_TRACE(TSTDOUT, 0, "lcddp_Sleep: calling hal_GoudaClose"); hal_GoudaClose(); g_lcddInSleep = TRUE; lcdd_MutexFree(); return LCDD_ERR_NO; }
// ============================================================================ // lcdd_Open // ---------------------------------------------------------------------------- /// Open the LCDD driver. /// It must be called before any call to any other function of this driver. /// This function is to be called only once. /// @return #LCDD_ERR_NO or #LCDD_ERR_DEVICE_NOT_FOUND. // ============================================================================ PRIVATE LCDD_ERR_T lcdd_Open(VOID) { g_lcddConfig = &g_tgtLcddCfg; hal_LcdcOpen(&g_lcddConfig->config, g_lcddConfig->timings); hal_TimDelay(20 MS_WAITING); //************* Start Initial Sequence **********// LCM_WR_REG(0x0001, 0x021c); // set SS and NL bit 0x001c LCM_WR_REG(0x0002, 0x0100); // set 1 line inversion // LCM_WR_REG(0x0003, 0x1028); // set GRAM write direction and BGR=1. //0x1030 modify for T33 LCM_WR_REG(0x0008, 0x0808); // set BP and FP LCM_WR_REG(0x000B, 0x1100); LCM_WR_REG(0x000C, 0x0000); // RGB interface setting R0Ch=0x0110 for RGB 18Bit and R0Ch=0111for RGB16Bit LCM_WR_REG(0x000F, 0x0e01); // Set frame rate //0a01 //*************Power On sequence ****************// hal_TimDelay(50 MS_WAITING); // Delay 50ms LCM_WR_REG(0x0010, 0x0800); // Set SAP,DSTB,STB LCM_WR_REG(0x0011, 0x1038); // Set APON,PON,AON,VCI1EN,VC hal_TimDelay(50 MS_WAITING); // Delay 50ms LCM_WR_REG(0x0012, 0x1000); // Internal reference voltage= Vci; LCM_WR_REG(0x0013, 0x0068); // Set GVDD LCM_WR_REG(0x0014, 0x4360); // Set VCOMH/VCOML voltage LCM_WR_REG(0x0015, 0x0020); //------------- Set GRAM area ------------------// LCM_WR_REG(0x0030, 0x0000); LCM_WR_REG(0x0031, 0x00DB); LCM_WR_REG(0x0032, 0x0000); LCM_WR_REG(0x0033, 0x0000); LCM_WR_REG(0x0034, 0x00DB); LCM_WR_REG(0x0035, 0x0000); LCM_WR_REG(0x0036, 0x00AF); LCM_WR_REG(0x0037, 0x0000); LCM_WR_REG(0x0038, 0x00DB); LCM_WR_REG(0x0039, 0x0000); LCM_WR_REG(0x0050, 0x0101); LCM_WR_REG(0x0051, 0x0b04); LCM_WR_REG(0x0052, 0x0006); LCM_WR_REG(0x0053, 0x0600); LCM_WR_REG(0x0054, 0x040b); LCM_WR_REG(0x0055, 0x0101); LCM_WR_REG(0x0056, 0x0503); LCM_WR_REG(0x0057, 0x0305); LCM_WR_REG(0x0058, 0x0106); LCM_WR_REG(0x0059, 0x0104); hal_TimDelay(50 MS_WAITING); // Delay 50ms LCM_WR_REG(0x0007, 0x1017); LCM_WR_CMD(0x0022); // Allow access g_lcddLock = 1; g_lcddOpened = TRUE; lcdd_SetDirRotationExt(LCDD_ROTATION_90); return LCDD_ERR_NO; }
// ============================================================================ // lcdd_Sleep // ---------------------------------------------------------------------------- /// Set the main LCD screen in sleep mode. /// @return #LCDD_ERR_NO or #LCDD_ERR_NOT_OPENED // ============================================================================ PRIVATE LCDD_ERR_T lcdd_Sleep(VOID) { LCDD_ASSERT(g_lcddOpened, "LCDD: Call to %s while LCDD is not opened", __FUNCTION__); LCM_WR_REG(0x0007, 0x0000); // Set D1=0, D0=1 hal_TimDelay(50 MS_WAITING); LCM_WR_REG(0x0011, 0x0007); // Set APON,PON,AON,VCI1EN,VC hal_TimDelay(50 MS_WAITING); LCM_WR_REG(0x0010, 0x0A01); // Enter Standby mode return LCDD_ERR_NO; }
// ============================================================================ // lcddp_SetDirRotation // ---------------------------------------------------------------------------- /// // ============================================================================ PRIVATE BOOL lcddp_SetDirRotation(VOID) { while (0 == lcdd_MutexGet()) { sxr_Sleep(LCDD_TIME_MUTEX_RETRY); } g_lcddRotate = TRUE; if (g_lcddInSleep) { lcdd_MutexFree(); return TRUE; } LCM_WR_CMD_8(0x36); //Set Scanning Direction LCM_WR_DATA_8(0xA8); hal_TimDelay(1 MS_WAITING); lcdd_MutexFree(); return TRUE; }
// ============================================================================ // lcddp_SetDirDefault // ---------------------------------------------------------------------------- /// // ============================================================================ PRIVATE BOOL lcddp_SetDirDefault(VOID) { while (0 == lcdd_MutexGet()) { sxr_Sleep(LCDD_TIME_MUTEX_RETRY); } g_lcddRotate = FALSE; if (g_lcddInSleep) { lcdd_MutexFree(); return TRUE; } main_Write_COM(0x36); //Set Scanning Direction main_Write_DATA(0xA8); //0xc0 //LCM_WR_REG(0x36,0xC8); // LCM_WR_CMD_8(0x36); //Set Scanning Direction // LCM_WR_DATA_8(0xC0); hal_TimDelay(1 MS_WAITING); lcdd_MutexFree(); return TRUE; }
// ============================================================================ // camerap_CheckProductId // ---------------------------------------------------------------------------- /// read sensor id,compare with define sensor id /// @return #TRUE, #FALSE // ============================================================================ PRIVATE BOOL camerap_CheckProductId() { UINT8 cameraID=0; camerap_Reserve(NULL); #ifdef I2C_BASED_ON_GPIO gpio_i2c_open(); #else g_camdI2cBusId = tgt_GetCamdConfig()->i2cBusId; hal_I2cOpen(g_camdI2cBusId); #endif HAL_CAMERA_CFG_T CamConfig = {0,}; CamConfig.rstActiveH = FALSE; CamConfig.pdnActiveH = TRUE; CamConfig.dropFrame = FALSE; CamConfig.camClkDiv = 6; // 156MHz/6 = 26MHz CamConfig.endianess = NO_SWAP;//BYTE_SWAP;// CamConfig.colRatio= COL_RATIO_1_1; CamConfig.rowRatio= ROW_RATIO_1_1; CamConfig.camId = camera_GetCameraID(); hal_CameraOpen(&CamConfig); hal_CameraReset(TRUE); // set reset to low // Enable Camera LDO pmd_EnablePower(PMD_POWER_CAMERA,TRUE); hal_TimDelay(819); // delay 5ms for stable reset low signal hal_CameraPowerDown(FALSE); if (gSensorInfo.snrrst) { } else { hal_CameraReset(FALSE); } //before read,must delay for sensor camerap_Delay(20); cameraID=camerap_GetId(); // Disable Camera Interface Module hal_CameraClose(); // Disable I2C #ifdef I2C_BASED_ON_GPIO gpio_i2c_close(); #else hal_I2cClose(g_camdI2cBusId); #endif // Disable the LDO for the camera pmd_EnablePower(PMD_POWER_CAMERA,FALSE); SXS_TRACE(TSTDOUT,"byd3703(0x%02x): read id is 0x%02x", CAM_BYD3703_ID, cameraID); if(cameraID == CAM_BYD3703_ID) return TRUE; else return FALSE; }
// ============================================================================ // pal_SimSetVoltage // ---------------------------------------------------------------------------- /// WARNING /// This function is called under IRQ. Fancy things like /// call to sxr_Sleep or mailbox creating are FORBIDDEN /// This function sets the SIM voltage. /// @param level Voltage to set. // ============================================================================ PUBLIC VOID pal_SetSimVoltage1(UINT8 level) { UINT32 delay; // Level 0 = Off // Level 1 = Class C (1.8V) // Level 2 = Class B (2.7 - 3.3V) // Level 3 = Class A (5V) delay = SETVOLT_DLY; switch (level) { case PAL_SIM_VOLTAGE_CLASS_A: pmd_SetLevel(PMD_LEVEL_SIM, PMD_SIM_VOLTAGE_5V0); break; case PAL_SIM_VOLTAGE_CLASS_B: pmd_SetLevel(PMD_LEVEL_SIM, PMD_SIM_VOLTAGE_3V0); break; case PAL_SIM_VOLTAGE_CLASS_C: pmd_SetLevel(PMD_LEVEL_SIM, PMD_SIM_VOLTAGE_1V8); break; case PAL_SIM_VOLTAGE_NULL: pmd_SetLevel(PMD_LEVEL_SIM, PMD_SIM_VOLTAGE_0V0); // Add extra delay for voltage 0 delay += NULLVOLT_DLY; break; } hal_TimDelay(delay MS_WAITING); }
PUBLIC DUALSIM_ERR_T foursim_SetSimVoltage_8806(DUALSIM_SIM_VOLTAGE_T sim0Level,DUALSIM_SIM_VOLTAGE_T sim1Level, DUALSIM_SIM_VOLTAGE_T sim2Level, DUALSIM_SIM_VOLTAGE_T sim3Level) { UINT32 delay; DUALSIM_ERR_T errStatus; // Level 0 = Off // Level 1 = Class C (1.8V) // Level 2 = Class B (2.7 - 3.3V) // Level 3 = Class A (5V) //2.8V UINT32 VoltErr_status = 0x55cc0000; UINT32 VoltErr_statusEDGE = 0x55dddddd; UINT32 VoltErr_statusSim = 0x55ee0000; errStatus = pmd_FourSimSetVoltageClass(sim0Level, sim1Level, sim2Level, sim3Level); // hal_HstSendEvent(VoltErr_status + errStatus); // hal_HstSendEvent(VoltErr_statusEDGE); // hal_HstSendEvent(VoltErr_statusSim + sim0Level); // hal_HstSendEvent(VoltErr_statusSim + sim1Level); // hal_HstSendEvent(VoltErr_statusSim + sim2Level); // hal_HstSendEvent(VoltErr_statusSim + sim3Level); // hal_HstSendEvent(VoltErr_statusEDGE); if (errStatus == DUALSIM_ERR_NO) { delay = DS_SETVOLT_DLY; hal_TimDelay(delay MS_WAITING); } return errStatus; }
// ============================================================================ // lcddp_WakeUp // ---------------------------------------------------------------------------- /// Wake the main LCD screen out of sleep mode /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED // ============================================================================ PRIVATE LCDD_ERR_T lcddp_WakeUp(VOID) { if (0 == lcdd_MutexGet()) { sxr_Sleep(LCDD_TIME_MUTEX_RETRY); LCDD_TRACE(TSTDOUT, 0, "LCDD: Wakeup while another LCD operation in progress. Sleep %d ticks", LCDD_TIME_MUTEX_RETRY); } if (!g_lcddInSleep) { lcdd_MutexFree(); return LCDD_ERR_NO; } LCDD_TRACE(TSTDOUT, 0, "lcddp_WakeUp: calling hal_GoudaOpen"); hal_GoudaOpen(&g_tgtLcddCfg.config, g_tgtLcddCfg.timings, 0); // Init code sxr_Sleep(100 MS_WAITING); // Delay 50 ms #if 0 LCM_WR_REG(0x0010, 0x0A00); // Exit Sleep/ Standby mode LCM_WR_REG(0x0011, 0x1038); // Set APON,PON,AON,VCI1EN,VC sxr_Sleep(50 MS_WAITING); LCM_WR_REG(0x0007, 0x1017); // Set D1=0, D0=1 #else main_Write_COM(0x11); //Exit Sleep hal_TimDelay(120 MS_WAITING); lcddp_Init(); #endif g_lcddInSleep = FALSE; lcdd_MutexFree(); // Set a comfortable background color to avoid screen flash LCDD_FBW_T frameBufferWin; frameBufferWin.fb.buffer = NULL; frameBufferWin.fb.colorFormat = LCDD_COLOR_FORMAT_RGB_565; frameBufferWin.roi.x=0; frameBufferWin.roi.y=0; if (g_lcddRotate) { frameBufferWin.roi.width = LCDD_DISP_Y; frameBufferWin.roi.height = LCDD_DISP_X; frameBufferWin.fb.width = LCDD_DISP_Y; frameBufferWin.fb.height = LCDD_DISP_X; } else { frameBufferWin.roi.width = LCDD_DISP_X; frameBufferWin.roi.height = LCDD_DISP_Y; frameBufferWin.fb.width = LCDD_DISP_X; frameBufferWin.fb.height = LCDD_DISP_Y; } lcddp_Blit16(&frameBufferWin,frameBufferWin.roi.x,frameBufferWin.roi.y); return LCDD_ERR_NO; }
PRIVATE VOID camerap_Delay(UINT16 Wait_mS) { UINT32 Ticks_16K; // Here is the delay function used by the camera driver. It can be changed to use a non-blocking // wait if necessary, but for now, just use hal_TimDelay Ticks_16K = (16348 * Wait_mS)/1000; hal_TimDelay(Ticks_16K); }
// ============================================================================ // lcdd_Sleep // ---------------------------------------------------------------------------- /// Set the main LCD screen in sleep mode. /// @return #LCDD_ERR_NO or #LCDD_ERR_NOT_OPENED // ============================================================================ PUBLIC LCDD_ERR_T lcdd_Sleep(VOID) { LCDD_ASSERT(g_lcddOpened, "LCDD: Call to %s while LCDD is not opened", __FUNCTION__); LCM_WR_REG(0x0007,0x0032); hal_TimDelay(20 MS_WAITING); LCM_WR_REG(0x0007,0x0022); hal_TimDelay(20 MS_WAITING); LCM_WR_REG(0x0007,0x0002); hal_TimDelay(20 MS_WAITING); LCM_WR_REG(0x0007,0x0000); hal_TimDelay(20 MS_WAITING); LCM_WR_REG(0x0013,0x0000); LCM_WR_REG(0x0012,0x0000); LCM_WR_REG(0x0010,0x0080); hal_TimDelay(20 MS_WAITING); LCM_WR_REG(0x0010,0x0002); return LCDD_ERR_NO; }
PRIVATE LCDD_ERR_T lcddp_Sleep(VOID) { while (0 == lcdd_MutexGet()) { sxr_Sleep(LCDD_TIME_MUTEX_RETRY); LCDD_TRACE(TSTDOUT, 0, "LCDD: Sleep while another LCD operation in progress. Sleep %d ticks", LCDD_TIME_MUTEX_RETRY); } if (g_lcddInSleep) { lcdd_MutexFree(); return LCDD_ERR_NO; } LCM_WR_REG(0x26,0xb8); hal_TimDelay(40 MS_WAITING); LCM_WR_REG(0x19,0x01); hal_TimDelay(40 MS_WAITING); LCM_WR_REG(0x26,0xa4); hal_TimDelay(40 MS_WAITING); LCM_WR_REG(0x26,0x84); hal_TimDelay(40 MS_WAITING); LCM_WR_REG(0x1c,0x00); LCM_WR_REG(0x01,0x02); LCM_WR_REG(0x01,0x00); LCDD_TRACE(TSTDOUT, 0, "lcddp_Sleep: calling hal_GoudaClose"); hal_GoudaClose(); g_lcddInSleep = TRUE; lcdd_MutexFree(); return LCDD_ERR_NO; }
// ============================================================================ // lcdd_Sleep // ---------------------------------------------------------------------------- /// Set the main LCD screen in sleep mode. /// @return #LCDD_ERR_NO or #LCDD_ERR_NOT_OPENED // ============================================================================ PRIVATE LCDD_ERR_T lcdd_Sleep(VOID) { LCDD_TRACE(LCDD_INFO_TRC, 0, "lcdd_Sleep"); if (0 == g_lcddCsBase) { return LCDD_ERR_NOT_OPENED; } else { LCM_WR_CMD_8(0x10); hal_TimDelay(120 MS_WAITING); return LCDD_ERR_NO; } }
// ============================================================================ // lcdd_CheckProductId // ---------------------------------------------------------------------------- /// read Lcd id,compare with define lcd id /// @return #TRUE, #FALSE // ============================================================================ PRIVATE BOOL lcdd_CheckProductId() { UINT16 productId=0; LCDD_CONFIG_T lcddReadConfig=LCDD_READ_CONFIG; hal_LcdcOpen(&lcddReadConfig.config, lcddReadConfig.timings); hal_TimDelay(20 MS_WAITING); hal_LcdcReadReg(0x0, &productId); hal_LcdcClose(); // force trace LCDD_TRACE(LCDD_INFO_TRC|TSTDOUT, 0, "1LCD otm2201h Id:%x ",productId); // if(productId ==LCD_otm2201h_ID) return TRUE; // else // return FALSE; }
// ============================================================================ // lcdd_WakeUp // ---------------------------------------------------------------------------- /// Wake the main LCD screen out of sleep mode /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED // ============================================================================ PUBLIC LCDD_ERR_T lcdd_WakeUp(VOID) { LCDD_ASSERT(g_lcddOpened, "LCDD: Call to %s while LCDD is not opened", __FUNCTION__); LCM_WR_REG(0x0007,0x0101); LCM_WR_REG(0x0010,0x15B0);//15b0 LCM_WR_REG(0x0011,0x0007); LCM_WR_REG(0x0017,0x0001); LCM_WR_REG(0x0012,0x01B5);//01b4 //01bc LCM_WR_REG(0x0013,0x1500); //0f00 LCM_WR_REG(0x0029,0x000f);//0009 hal_TimDelay(10 MS_WAITING); LCM_WR_REG(0x0007,0x0173); LCM_WR_CMD(0x0022); return LCDD_ERR_NO; }
// ============================================================================ // lcdd_WakeUp // ---------------------------------------------------------------------------- /// Wake the main LCD screen out of sleep mode /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED // ============================================================================ PUBLIC LCDD_ERR_T lcdd_WakeUp(VOID) { LCDD_TRACE(LCDD_INFO_TRC, 0, "lcdd_WakeUp"); if (0 == g_lcddCsBase) { return LCDD_ERR_NOT_OPENED; } else { // Standby Mode OFF LCM_WR_CMD(0x2C); hal_TimDelay(20 MS_WAITING); // Turn ON Oscillator LCM_WR_CMD(0x02); LCM_WR_CMD(0x01); hal_TimDelay(20 MS_WAITING); // DCDC1 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x01); hal_TimDelay(20 MS_WAITING); // AMP ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x09); hal_TimDelay(20 MS_WAITING); // DCDC2 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x0B); hal_TimDelay(20 MS_WAITING); // DCDC3 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x0F); hal_TimDelay(100 MS_WAITING); // Display On LCM_WR_CMD(0x51); return LCDD_ERR_NO; } }
// ============================================================================ // lcdd_WakeUp // ---------------------------------------------------------------------------- /// Wake the main LCD screen out of sleep mode /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED // ============================================================================ PUBLIC LCDD_ERR_T lcdd_WakeUp(VOID) { LCDD_ASSERT(g_lcddOpened, "LCDD: Call to %s while LCDD is not opened", __FUNCTION__); // Standby Mode OFF LCM_WR_CMD(0x2C); hal_TimDelay(20 MS_WAITING); // Turn ON Oscillator LCM_WR_CMD(0x02); LCM_WR_CMD(0x01); hal_TimDelay(20 MS_WAITING); // DCDC1 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x01); hal_TimDelay(20 MS_WAITING); // AMP ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x09); hal_TimDelay(20 MS_WAITING); // DCDC2 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x0B); hal_TimDelay(20 MS_WAITING); // DCDC3 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x0F); hal_TimDelay(100 MS_WAITING); // Display On LCM_WR_CMD(0x51); return LCDD_ERR_NO; }
// ============================================================================ // hal_KeyOpen // ---------------------------------------------------------------------------- /// This function initializes the keypad driver. The configuration of the key /// pins used is board dependent and is built in HAL through the /// #tgt_BoardConfig.halCfg structure. /// /// @param debounceTime defines the time to wait for debounce, in number of /// 16384Hz steps. Boundaries applied to the possible values of this time, /// which are dependent on the board config, especially the number of /// out line of the keypad: the value of this parameter must be chosen /// between 5*Number of Enabled KeyOu and 1280*Number of Enabled /// Please refer to the keypad documentation for /// details. /// @param kpItvTime defines the interval time between the generation of IRQ /// when one or more keys are being held down. It defines a multiple of the /// debounce time. // ============================================================================ PUBLIC VOID hal_KeyOpen(UINT16 debounceTime, UINT16 kpItvTime) { CONST HAL_CFG_CONFIG_T* halCfg = g_halCfg; UINT32 keyOutMask = halCfg->keyOutMask | 0x1; UINT32 temp; UINT32 nbKeyOut = 0; // Debounce value to enter in the control reg UINT32 dbnTimeReg = 0; // Save current OnOff key status for power-on check (Otherwise // we will have to wait the debounce time after enabling keypad. // See the last comments of this function) hal_KeyOnOffStateAtPowerOn(); // Count the number of enabled keyout. temp = keyOutMask; while (temp != 0) { if (temp & 0x1) { nbKeyOut += 1; } temp = temp >>1; } #ifdef TGT_WITH_EXPKEY g_ExpKeyCfg = tgt_GetExpKeyConfig(); if (g_ExpKeyCfg->expKeyUsed) { g_keyOut6 = g_ExpKeyCfg->expKeyOut6; g_keyOut7 = g_ExpKeyCfg->expKeyOut7; if ((g_keyOut6.type == HAL_GPIO_TYPE_O) && (g_keyOut7.type == HAL_GPIO_TYPE_O)) { hal_GpioSet(g_keyOut6); hal_GpioSet(g_keyOut7); } else { HAL_ASSERT(FALSE, "Should Use GPO as KeyOut!"); } } #endif // Reset the event generation configuration. g_eventOnUp = FALSE; g_eventOnPressed = FALSE; g_eventOnDown = FALSE; g_keyIrqHandler = NULL; // Initialize the previous state. g_previousKeys[0] = 0; g_previousKeys[1] = 0; g_previousOnOff = hal_KeyOnOffStateGet(); if(nbKeyOut != 0) { HAL_ASSERT( (debounceTime >= 5 * nbKeyOut ) && (debounceTime <= 256*5*nbKeyOut), "Improper debounce times used: %d", debounceTime); // Value to enter in the register bitfield // De-bounce time = (KP_DBN_TIME + 1) * SCAN_TIME, // SCAN_TIME = 0.3125 ms * Number of Enabled KeyOut (determined by KP_OUT_MASK). // For example, if KP_DBN_TIME = 7, KP_OUT_MASK = "111111", then // De-bounce time = (7+1)*0.3125*6=15 ms. The maximum debounce time is 480 ms. dbnTimeReg = (debounceTime / (5 * nbKeyOut)) - 1; } else { dbnTimeReg = (debounceTime) - 1; } // Ensure keypad runs out of its state machine // (Keypad might have been enabled at boot time) hwp_keypad->KP_CTRL = 0; // It needs 1 cycle of 16K clock to disable keypad hal_TimDelay(3); hwp_keypad->KP_CTRL = KEYPAD_KP_DBN_TIME(dbnTimeReg) | KEYPAD_KP_ITV_TIME(kpItvTime) | KEYPAD_KP_EN | KEYPAD_KP_IN_MASK(halCfg->keyInMask) | KEYPAD_KP_OUT_MASK(keyOutMask); // clear current IRQ hwp_keypad->KP_IRQ_CLR = KEYPAD_KP_IRQ_CLR; //g_halMapAccess.keypadPulseHandler = (void*)hal_KeyRemoteHandler; #ifdef TGT_WITH_EXPKEY g_kpItvReg = kpItvTime; g_kpdbReg = dbnTimeReg; g_kpCtrlReg = KEYPAD_KP_ITV_IRQ_MASK | KEYPAD_KP_EVT1_IRQ_MASK | KEYPAD_KP_EVT0_IRQ_MASK | KEYPAD_KP_EN | KEYPAD_KP_IN_MASK(halCfg->keyInMask) | KEYPAD_KP_OUT_MASK(keyOutMask); #endif // !!! CAUTION !!! // After keypad is enabled, the status of individual keys (including // OnOff key) will NOT be available until the debouce time elapses. }
// ============================================================================ // hal_I2cSendByte // ---------------------------------------------------------------------------- /// This function write one byte at a given address of a given slave. /// /// @param id ID of the I2C bus /// @param slaveAddr Address of the slave to which we write a byte. /// @param memAddr Address on the slave's memmory map where to write the /// data byte. /// @param data Byte to write /// @return #HAL_ERR_NO or #HAL_ERR_RESOURCE_BUSY, if the I2C FIFO is full /// at that time, or HAL_ERR_COMMUNICATION_FAILED. // ============================================================================ PUBLIC HAL_ERR_T hal_I2cSendByte(HAL_I2C_BUS_ID_T id, UINT32 slaveAddr, UINT32 memAddr, UINT8 data) { HAL_ASSERT(id<HAL_I2C_BUS_ID_QTY && g_halI2cOpened[id], g_halI2cErrStrIdNotActive, id); HWP_I2C_MASTER_T* CONST i2cMaster = g_halI2cMasterAddr[id]; HAL_I2C_TAKE_BUS(id); hal_TimDelay(HAL_I2C_SEND_BYTE_DELAY); // test bus availability if (i2cMaster->STATUS & (I2C_MASTER_TIP|I2C_MASTER_BUSY)) { HAL_I2C_RELEASE_BUS(id); return HAL_ERR_RESOURCE_BUSY; } // Clear status bit in case previous transfer (Raw) hasn't // cleared it. i2cMaster->IRQ_CLR = I2C_MASTER_IRQ_CLR; // Write slave address i2cMaster -> TXRX_BUFFER = (slaveAddr << 1); i2cMaster -> CMD = I2C_MASTER_WR | I2C_MASTER_STA; // Polling on the TIP flag /* while(i2cMaster -> STATUS & I2C_MASTER_TIP); */ while(!(i2cMaster -> STATUS & I2C_MASTER_IRQ_STATUS)); i2cMaster->IRQ_CLR = I2C_MASTER_IRQ_CLR; // Transfert done // Check RxACK if (i2cMaster -> STATUS & I2C_MASTER_RXACK) { // Abort the transfert i2cMaster -> CMD = I2C_MASTER_STO ; while(!(i2cMaster -> STATUS & I2C_MASTER_IRQ_STATUS)); i2cMaster->IRQ_CLR = I2C_MASTER_IRQ_CLR; HAL_I2C_RELEASE_BUS(id); return HAL_ERR_COMMUNICATION_FAILED; } // Write memory address i2cMaster -> TXRX_BUFFER = memAddr; i2cMaster -> CMD = I2C_MASTER_WR; // Polling on the TIP flag /* while(i2cMaster -> STATUS & I2C_MASTER_TIP); */ while(!(i2cMaster -> STATUS & I2C_MASTER_IRQ_STATUS)); i2cMaster->IRQ_CLR = I2C_MASTER_IRQ_CLR; // Check RxACK if (i2cMaster -> STATUS & I2C_MASTER_RXACK) { // Abort the transfert i2cMaster -> CMD = I2C_MASTER_STO ; while(!(i2cMaster -> STATUS & I2C_MASTER_IRQ_STATUS)); i2cMaster->IRQ_CLR = I2C_MASTER_IRQ_CLR; HAL_I2C_RELEASE_BUS(id); return HAL_ERR_COMMUNICATION_FAILED; } // Write Value i2cMaster -> TXRX_BUFFER = data; i2cMaster -> CMD = I2C_MASTER_WR | I2C_MASTER_STO ; // Polling on the TIP flag /* while(i2cMaster -> STATUS & I2C_MASTER_TIP); */ while(!(i2cMaster -> STATUS & I2C_MASTER_IRQ_STATUS)); i2cMaster->IRQ_CLR = I2C_MASTER_IRQ_CLR; // Check RxACK if (i2cMaster -> STATUS & I2C_MASTER_RXACK) { // Stop condition sent via the previous // command HAL_I2C_RELEASE_BUS(id); return HAL_ERR_COMMUNICATION_FAILED; } HAL_I2C_RELEASE_BUS(id); return HAL_ERR_NO; }
// ============================================================================ // lcdd_WakeUp // ---------------------------------------------------------------------------- /// Wake the main LCD screen out of sleep mode /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED // ============================================================================ PRIVATE LCDD_ERR_T lcdd_WakeUp(VOID) { LCDD_TRACE(LCDD_INFO_TRC, 0, "lcdd_WakeUp"); if (0 == g_lcddCsBase) { return LCDD_ERR_NOT_OPENED; } else { main_Write_COM(0x11); //Exit Sleep hal_TimDelay(120 MS_WAITING); main_Write_COM(0x26); //Set Default Gamma main_Write_DATA(0x04); main_Write_COM(0xB1); main_Write_DATA(0x08); main_Write_DATA(0x14); main_Write_COM(0xC0); //Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD main_Write_DATA(0x08); main_Write_DATA(0x00); main_Write_COM(0xC1); //Set BT[2:0] for AVDD & VCL & VGH & VGL main_Write_DATA(0x05); main_Write_COM(0xC5); //Set VMH[6:0] & VML[6:0] for VOMH & VCOML main_Write_DATA(0x46);//0x46 main_Write_DATA(0x40);//0x40 main_Write_COM(0xC7); main_Write_DATA(0xBD); //0xC2 main_Write_COM(0x3a); //Set Color Format main_Write_DATA(0x05); main_Write_COM(0x2A); //Set Column Address main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x7F); main_Write_COM(0x2B); //Set Page Address main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x9F); main_Write_COM(0xB4); //Set Source Output Direction main_Write_DATA(0x00); main_Write_COM(0xf2); //Enable Gamma bit main_Write_DATA(0x01); main_Write_COM(0x36); //Set Scanning Direction main_Write_DATA(0xC8); //0xc0 main_Write_COM(0xE0); main_Write_DATA(0x3F);//p1 main_Write_DATA(0x26);//p2 main_Write_DATA(0x23);//p3 main_Write_DATA(0x30);//p4 main_Write_DATA(0x28);//p5 main_Write_DATA(0x10);//p6 main_Write_DATA(0x55);//p7 main_Write_DATA(0xB7);//p8 main_Write_DATA(0x40);//p9 main_Write_DATA(0x19);//p10 main_Write_DATA(0x10);//p11 main_Write_DATA(0x1E);//p12 main_Write_DATA(0x02);//p13 main_Write_DATA(0x01);//p14 main_Write_DATA(0x00);//p15 main_Write_COM(0xE1); main_Write_DATA(0x00);//p1 main_Write_DATA(0x19);//p2 main_Write_DATA(0x1C);//p3 main_Write_DATA(0x0F);//p4 main_Write_DATA(0x14);//p5 main_Write_DATA(0x0F);//p6 main_Write_DATA(0x2A);//p7 main_Write_DATA(0x48);//p8 main_Write_DATA(0x3F);//p9 main_Write_DATA(0x06);//p10 main_Write_DATA(0x1D);//p11 main_Write_DATA(0x21);//p12 main_Write_DATA(0x3D);//p13 main_Write_DATA(0x3E);//p14 main_Write_DATA(0x3F);//p15 main_Write_COM(0x29); // Display On return LCDD_ERR_NO; } }
// ============================================================================ // lcdd_Open // ---------------------------------------------------------------------------- /// Open the LCDD driver. /// It must be called before any call to any other function of this driver. /// This function is to be called only once. /// @return #LCDD_ERR_NO or #LCDD_ERR_DEVICE_NOT_FOUND. // ============================================================================ PRIVATE LCDD_ERR_T lcdd_Open(VOID) { g_lcddConfig = &g_tgtLcddCfg; g_lcddCsBase = (UINT32) hal_EbcCsOpen(g_lcddConfig->csNum, &g_lcddConfig->csConfig); g_lcddCsOffset = EXP2(g_lcddConfig->rsLine+1); if (0 == g_lcddCsBase) { return LCDD_ERR_DEVICE_NOT_FOUND; } else { // Turn off backlight so that we don't display anything wrong hal_SysResetOut(FALSE); //--************ Start Initial Sequence **********--// main_Write_COM(0x11); //Exit Sleep hal_TimDelay(120 MS_WAITING); main_Write_COM(0x26); //Set Default Gamma main_Write_DATA(0x04); main_Write_COM(0xB1); main_Write_DATA(0x08); main_Write_DATA(0x14); main_Write_COM(0xC0); //Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD main_Write_DATA(0x08); main_Write_DATA(0x00); main_Write_COM(0xC1); //Set BT[2:0] for AVDD & VCL & VGH & VGL main_Write_DATA(0x05); main_Write_COM(0xC5); //Set VMH[6:0] & VML[6:0] for VOMH & VCOML main_Write_DATA(0x46);//0x46 main_Write_DATA(0x40);//0x40 main_Write_COM(0xC7); main_Write_DATA(0xBD); //0xC2 main_Write_COM(0x3a); //Set Color Format main_Write_DATA(0x05); main_Write_COM(0x2A); //Set Column Address main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x7F); main_Write_COM(0x2B); //Set Page Address main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x9F); main_Write_COM(0xB4); //Set Source Output Direction main_Write_DATA(0x00); main_Write_COM(0xf2); //Enable Gamma bit main_Write_DATA(0x01); main_Write_COM(0x36); //Set Scanning Direction main_Write_DATA(0xC8); //0xc0 main_Write_COM(0xE0); main_Write_DATA(0x3F);//p1 main_Write_DATA(0x26);//p2 main_Write_DATA(0x23);//p3 main_Write_DATA(0x30);//p4 main_Write_DATA(0x28);//p5 main_Write_DATA(0x10);//p6 main_Write_DATA(0x55);//p7 main_Write_DATA(0xB7);//p8 main_Write_DATA(0x40);//p9 main_Write_DATA(0x19);//p10 main_Write_DATA(0x10);//p11 main_Write_DATA(0x1E);//p12 main_Write_DATA(0x02);//p13 main_Write_DATA(0x01);//p14 main_Write_DATA(0x00);//p15 main_Write_COM(0xE1); main_Write_DATA(0x00);//p1 main_Write_DATA(0x19);//p2 main_Write_DATA(0x1C);//p3 main_Write_DATA(0x0F);//p4 main_Write_DATA(0x14);//p5 main_Write_DATA(0x0F);//p6 main_Write_DATA(0x2A);//p7 main_Write_DATA(0x48);//p8 main_Write_DATA(0x3F);//p9 main_Write_DATA(0x06);//p10 main_Write_DATA(0x1D);//p11 main_Write_DATA(0x21);//p12 main_Write_DATA(0x3D);//p13 main_Write_DATA(0x3E);//p14 main_Write_DATA(0x3F);//p15 main_Write_COM(0x29); // Display On // Allow access g_lcddLock = 1; LCDD_TRACE(LCDD_INFO_TRC, 0, "lcdd_Open: LCD Opened"); return LCDD_ERR_NO; } }
// ============================================================================ // lcdd_Open // ---------------------------------------------------------------------------- /// Open the LCDD driver. /// It must be called before any call to any other function of this driver. /// This function is to be called only once. /// @return #LCDD_ERR_NO or #LCDD_ERR_DEVICE_NOT_FOUND. // ============================================================================ PRIVATE LCDD_ERR_T lcdd_Open(VOID) { SXS_TRACE(TSTDOUT,"#### DRV_LCD: Power On ####"); g_lcddConfig = &g_tgtLcddCfg; hal_LcdcOpen(&g_lcddConfig->config, g_lcddConfig->timings); // Init code hal_TimDelay(50 MS_WAITING); // Delay 50 ms hal_TimDelay(50 MS_WAITING); // Delay 50 ms //************* Start Initial Sequence **********// LCM_WR_REG(0x0001, 0x021c); // set SS and NL bit 0x001c LCM_WR_REG(0x0002, 0x0100); // set 1 line inversion LCM_WR_REG(0x0003, 0x1000); // set GRAM write direction and BGR=1. //0x1030 modify for T33 LCM_WR_REG(0x0008, 0x0808); // set BP and FP LCM_WR_REG(0x000C, 0x0003); // RGB interface setting R0Ch=0x0110 for RGB 18Bit and R0Ch=0111for RGB16Bit LCM_WR_REG(0x000F, 0x0a01); // Set frame rate //0a01 LCM_WR_REG(0x0020, 0x00AF); // Set GRAM Address LCM_WR_REG(0x0021, 0x00DB); // Set GRAM Address //*************Power On sequence ****************// hal_TimDelay(50 MS_WAITING); // Delay 50ms LCM_WR_REG(0x0010, 0x0800); // Set SAP,DSTB,STB LCM_WR_REG(0x0011, 0x1038); // Set APON,PON,AON,VCI1EN,VC hal_TimDelay(50 MS_WAITING); // Delay 50ms LCM_WR_REG(0x0012, 0x1121); // Internal reference voltage= Vci; LCM_WR_REG(0x0013, 0x0063); // Set GVDD LCM_WR_REG(0x0014, 0x4444); // Set VCOMH/VCOML voltage //------------- Set GRAM area ------------------// LCM_WR_REG(0x0030, 0x0000); LCM_WR_REG(0x0031, 0x00DB); LCM_WR_REG(0x0032, 0x0000); LCM_WR_REG(0x0033, 0x0000); LCM_WR_REG(0x0034, 0x00DB); LCM_WR_REG(0x0035, 0x0000); LCM_WR_REG(0x0036, 0x00AF); LCM_WR_REG(0x0037, 0x0000); LCM_WR_REG(0x0038, 0x00DB); LCM_WR_REG(0x0039, 0x0000); // ----------- Adjust the Gamma Curve ----------// LCM_WR_REG(0x0001, 0x021c); // set SS and NL bit 0x001c LCM_WR_REG(0x0002, 0x0100); // set 1 line inversion LCM_WR_REG(0x0003, 0x1000); // set GRAM write direction and BGR=1. //0x1010 LCM_WR_REG(0x0008, 0x0808); // set BP and FP LCM_WR_REG(0x000C, 0x0003); // RGB interface setting R0Ch=0x0110 for RGB 18Bit and R0Ch=0111for RGB16Bit LCM_WR_REG(0x000F, 0x0a01); // Set frame rate //0a01 LCM_WR_REG(0x0020, 0x00AF); // Set GRAM Address LCM_WR_REG(0x0021, 0x00DB); // Set GRAM Address //*************Power On sequence ****************// hal_TimDelay(50 MS_WAITING); // Delay 50ms LCM_WR_REG(0x0010, 0x0800); // Set SAP,DSTB,STB LCM_WR_REG(0x0011, 0x1038); // Set APON,PON,AON,VCI1EN,VC hal_TimDelay(50 MS_WAITING); // Delay 50ms LCM_WR_REG(0x0012, 0x1121); // Internal reference voltage= Vci; LCM_WR_REG(0x0013, 0x0063); // Set GVDD LCM_WR_REG(0x0014, 0x4444); // Set VCOMH/VCOML voltage LCM_WR_REG(0x0050, 0x0400); LCM_WR_REG(0x0051, 0x080B); LCM_WR_REG(0x0052, 0x0E0C); LCM_WR_REG(0x0053, 0x0103); LCM_WR_REG(0x0054, 0x0C0E); LCM_WR_REG(0x0055, 0x0B08); LCM_WR_REG(0x0056, 0x0004); LCM_WR_REG(0x0057, 0x0301); LCM_WR_REG(0x0058, 0x0E00); LCM_WR_REG(0x0059, 0x000E); hal_TimDelay(50 MS_WAITING); // Delay 50ms LCM_WR_REG(0x0007, 0x1017); LCM_WR_CMD(0x0022); // Allow access g_lcddLock = 1; g_lcddOpened = TRUE; return LCDD_ERR_NO; }
PRIVATE VOID lcddp_Init(VOID) { // Init code LCM_WR_CMD(0x01); hal_TimDelay(100 MS_WAITING); //--************ Start Initial Sequence **********--// main_Write_COM(0x11); //Exit Sleep hal_TimDelay(120 MS_WAITING); main_Write_COM(0x26); //Set Default Gamma main_Write_DATA(0x04); main_Write_COM(0xB1); main_Write_DATA(0x08); main_Write_DATA(0x14); main_Write_COM(0xC0); //Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD main_Write_DATA(0x08); main_Write_DATA(0x00); main_Write_COM(0xC1); //Set BT[2:0] for AVDD & VCL & VGH & VGL main_Write_DATA(0x05); main_Write_COM(0xC5); //Set VMH[6:0] & VML[6:0] for VOMH & VCOML main_Write_DATA(0x46);//0x46 main_Write_DATA(0x40);//0x40 main_Write_COM(0xC7); main_Write_DATA(0xBD); //0xC2 main_Write_COM(0x3a); //Set Color Format main_Write_DATA(0x05); main_Write_COM(0x2A); //Set Column Address main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x7F); main_Write_COM(0x2B); //Set Page Address main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x9F); main_Write_COM(0xB4); //Set Source Output Direction main_Write_DATA(0x00); main_Write_COM(0xf2); //Enable Gamma bit main_Write_DATA(0x01); main_Write_COM(0x36); //Set Scanning Direction main_Write_DATA(0xA8); //0xc0 main_Write_COM(0xE0); main_Write_DATA(0x3F);//p1 main_Write_DATA(0x26);//p2 main_Write_DATA(0x23);//p3 main_Write_DATA(0x30);//p4 main_Write_DATA(0x28);//p5 main_Write_DATA(0x10);//p6 main_Write_DATA(0x55);//p7 main_Write_DATA(0xB7);//p8 main_Write_DATA(0x40);//p9 main_Write_DATA(0x19);//p10 main_Write_DATA(0x10);//p11 main_Write_DATA(0x1E);//p12 main_Write_DATA(0x02);//p13 main_Write_DATA(0x01);//p14 main_Write_DATA(0x00);//p15 main_Write_COM(0xE1); main_Write_DATA(0x00);//p1 main_Write_DATA(0x19);//p2 main_Write_DATA(0x1C);//p3 main_Write_DATA(0x0F);//p4 main_Write_DATA(0x14);//p5 main_Write_DATA(0x0F);//p6 main_Write_DATA(0x2A);//p7 main_Write_DATA(0x48);//p8 main_Write_DATA(0x3F);//p9 main_Write_DATA(0x06);//p10 main_Write_DATA(0x1D);//p11 main_Write_DATA(0x21);//p12 main_Write_DATA(0x3D);//p13 main_Write_DATA(0x3E);//p14 main_Write_DATA(0x3F);//p15 main_Write_COM(0x29); // Display On LCM_WR_CMD_8(0x2c); //WRITE ram Data display hal_TimDelay(100 MS_WAITING); }
PRIVATE UINT16 lcddp_Open_Read_LcdId(VOID) { // return 1; UINT32 count; // UINT8 data[6] = {0x0,0x0,0x0,0x0,0x0,0x0}; // UINT8 iTempData[6] = {0x9, 0xff,0xff,0xff,0xff,0xff}; UINT8 data[3] = {0x0,0x0,0x0}; UINT8 iTempData[3] = {0xdb,0xff, 0xff}; // UINT8 dummy = 0; HAL_SPI_CFG_T slcd_spiCfg = { .enabledCS = HAL_SPI_CS0, .csActiveLow = TRUE, .inputEn = TRUE, .clkFallEdge = TRUE, .clkDelay = HAL_SPI_HALF_CLK_PERIOD_0, .doDelay = HAL_SPI_HALF_CLK_PERIOD_0, .diDelay = HAL_SPI_HALF_CLK_PERIOD_1, .csDelay = HAL_SPI_HALF_CLK_PERIOD_1, .csPulse = HAL_SPI_HALF_CLK_PERIOD_0,//HAL_SPI_HALF_CLK_PERIOD_1 .frameSize = 8, .oeRatio = 8, .spiFreq = 1000000,//5M 5000000 .rxTrigger = HAL_SPI_RX_TRIGGER_4_BYTE, .txTrigger = HAL_SPI_TX_TRIGGER_1_EMPTY, .rxMode = HAL_SPI_DIRECT_POLLING, .txMode = HAL_SPI_DIRECT_POLLING, .mask = {0,0,0,0,0}, .handler = NULL }; hal_SpiOpen(HAL_SPI,HAL_SPI_CS0, &slcd_spiCfg); hal_SpiActivateCs(HAL_SPI,HAL_SPI_CS0); hal_GpioClr(g_slcd_a0); // hal_SpiSendData(HAL_SPI,HAL_SPI_CS0,&dummy,1); //wait until any previous transfers have ended // while(!hal_SpiTxFinished(HAL_SPI,HAL_SPI_CS0));hal_GpioSet(g_slcd_a0); hal_SpiSendData(HAL_SPI,HAL_SPI_CS0,iTempData,3); //wait until any previous transfers have ended while(!hal_SpiTxFinished(HAL_SPI,HAL_SPI_CS0));//hal_GpioSet(g_slcd_a0); count = hal_SpiGetData(HAL_SPI,HAL_SPI_CS0,data, 3); hal_SpiDeActivateCs(HAL_SPI,HAL_SPI_CS0); hal_SpiClose(HAL_SPI,HAL_SPI_CS0); SXS_TRACE(TSTDOUT, "hx8535d: lcd read id is 0x%x 0x%x 0x%x ,count=%d",data[0],data[1],data[2],count); return (UINT16)data[1]; } PRIVATE VOID lcddp_Open_Spi(VOID) { HAL_SPI_CFG_T slcd_spiCfg = { .enabledCS = HAL_SPI_CS0, .csActiveLow = TRUE, .inputEn = TRUE, .clkFallEdge = TRUE, .clkDelay = HAL_SPI_HALF_CLK_PERIOD_0, .doDelay = HAL_SPI_HALF_CLK_PERIOD_0, .diDelay = HAL_SPI_HALF_CLK_PERIOD_1, .csDelay = HAL_SPI_HALF_CLK_PERIOD_1, .csPulse = HAL_SPI_HALF_CLK_PERIOD_0,//HAL_SPI_HALF_CLK_PERIOD_1 .frameSize = 8, .oeRatio = 0, .spiFreq = 20000000,//5M 5000000 15M 20M(33ms-per-frame) 39M(13ms-per-frame) .rxTrigger = HAL_SPI_RX_TRIGGER_4_BYTE, .txTrigger = HAL_SPI_TX_TRIGGER_1_EMPTY, .rxMode = HAL_SPI_DIRECT_POLLING, .txMode = HAL_SPI_DMA_POLLING, .mask = {0,0,0,0,0}, .handler = NULL }; hal_SpiOpen(HAL_SPI,HAL_SPI_CS0, &slcd_spiCfg); } // ============================================================================ // lcddp_Open // ---------------------------------------------------------------------------- /// Open the LCDD driver. /// It must be called before any call to any other function of this driver. /// This function is to be called only once. /// @return #LCDD_ERR_NO or #LCDD_ERR_DEVICE_NOT_FOUND. // ============================================================================ PRIVATE LCDD_ERR_T lcddp_Open(VOID) { hal_HstSendEvent(0x88855503); //hal_GoudaOpen(&g_tgtLcddCfg.config, g_tgtLcddCfg.timings, 0); hal_GpioSetOut(g_slcd_a0.gpioId); lcddp_Open_Spi(); lcddp_Init(); hal_TimDelay(1 MS_WAITING); g_lcddInSleep = FALSE; return LCDD_ERR_NO; } // ============================================================================ // lcddp_Close // ---------------------------------------------------------------------------- /// Close the LCDD driver /// No other functions of this driver should be called after a call to /// #lcddp_Close. /// @return #LCDD_ERR_NO or #LCDD_ERR_DEVICE_NOT_FOUND. // ============================================================================ PRIVATE LCDD_ERR_T lcddp_Close(VOID) { // hal_GoudaClose(); lcddp_SpiDeActivateCs(); return LCDD_ERR_NO; } // ============================================================================ // lcddp_SetContrast // ---------------------------------------------------------------------------- /// Set the contrast of the 'main'LCD screen. /// @param contrast Value to set the contrast to. /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED or /// #LCDD_ERR_INVALID_PARAMETER. // ============================================================================ PRIVATE LCDD_ERR_T lcddp_SetContrast(UINT32 contrast) { //#warning This function is not implemented yet return LCDD_ERR_NO; } // ============================================================================ // lcddp_SetStandbyMode // ---------------------------------------------------------------------------- /// Set the main LCD in standby mode or exit from it /// @param standbyMode If \c TRUE, go in standby mode. /// If \c FALSE, cancel standby mode. /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED or /// #LCDD_ERR_INVALID_PARAMETER. // ============================================================================ PRIVATE LCDD_ERR_T lcddp_SetStandbyMode(BOOL standbyMode) { if (standbyMode) { lcddp_Sleep(); } else { lcddp_WakeUp(); } return LCDD_ERR_NO; } // ============================================================================ // lcddp_Sleep // ---------------------------------------------------------------------------- /// Set the main LCD screen in sleep mode. /// @return #LCDD_ERR_NO or #LCDD_ERR_NOT_OPENED // ============================================================================ PRIVATE LCDD_ERR_T lcddp_Sleep(VOID) { while (0 == lcdd_MutexGet()) { sxr_Sleep(LCDD_TIME_MUTEX_RETRY); LCDD_TRACE(TSTDOUT, 0, "LCDD: Sleep while another LCD operation in progress. Sleep %d ticks", LCDD_TIME_MUTEX_RETRY); } if (g_lcddInSleep) { lcdd_MutexFree(); return LCDD_ERR_NO; } WriteCommand_Addr(0x10); //Set Sleep In sxr_Sleep(10 MS_WAITING); LCDD_TRACE(TSTDOUT, 0, "lcddp_Sleep: calling hal_GoudaClose"); g_lcddInSleep = TRUE; hal_SpiDeActivateCs(HAL_SPI,HAL_SPI_CS0); lcdd_MutexFree(); return LCDD_ERR_NO; } // ============================================================================ // lcddp_PartialOn // ---------------------------------------------------------------------------- /// Set the Partial mode of the LCD /// @param vsa : Vertical Start Active /// @param vea : Vertical End Active /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED // ============================================================================ PRIVATE LCDD_ERR_T lcddp_PartialOn(UINT16 vsa, UINT16 vea) { return LCDD_ERR_NO; } // ============================================================================ // lcddp_PartialOff // ---------------------------------------------------------------------------- /// return to Normal Mode /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED // ============================================================================ PRIVATE LCDD_ERR_T lcddp_PartialOff(VOID) { return LCDD_ERR_NO; } // ============================================================================ // lcddp_WakeUp // ---------------------------------------------------------------------------- /// Wake the main LCD screen out of sleep mode /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED // ============================================================================ PRIVATE LCDD_ERR_T lcddp_WakeUp(VOID) { if (0 == lcdd_MutexGet()) { sxr_Sleep(LCDD_TIME_MUTEX_RETRY); LCDD_TRACE(TSTDOUT, 0, "LCDD: Wakeup while another LCD operation in progress. Sleep %d ticks", LCDD_TIME_MUTEX_RETRY); } if (!g_lcddInSleep) { lcdd_MutexFree(); return LCDD_ERR_NO; } LCDD_TRACE(TSTDOUT, 0, "lcddp_WakeUp: calling hal_GoudaOpen"); // hal_GoudaOpen(&g_tgtLcddCfg.config, g_tgtLcddCfg.timings, 0); #if 0 lcddp_SpiActivateCs(); WriteCommand_Addr(0x11); //Set Sleep Out sxr_Sleep(120 MS_WAITING); #else lcddp_Init(); #endif g_lcddInSleep = FALSE; lcdd_MutexFree(); // Set a comfortable background color to avoid screen flash LCDD_FBW_T frameBufferWin; frameBufferWin.fb.buffer = NULL; frameBufferWin.fb.colorFormat = LCDD_COLOR_FORMAT_RGB_565; frameBufferWin.roi.x=0; frameBufferWin.roi.y=0; if (g_lcddRotate) { frameBufferWin.roi.width = LCDD_DISP_Y; frameBufferWin.roi.height = LCDD_DISP_X; frameBufferWin.fb.width = LCDD_DISP_Y; frameBufferWin.fb.height = LCDD_DISP_X; } else { frameBufferWin.roi.width = LCDD_DISP_X; frameBufferWin.roi.height = LCDD_DISP_Y; frameBufferWin.fb.width = LCDD_DISP_X; frameBufferWin.fb.height = LCDD_DISP_Y; } lcddp_Blit16(&frameBufferWin,frameBufferWin.roi.x,frameBufferWin.roi.y); return LCDD_ERR_NO; } // ============================================================================ // lcddp_GetScreenInfo // ---------------------------------------------------------------------------- /// Get information about the main LCD device. /// @param screenInfo Pointer to the structure where the information /// obtained will be stored /// @return #LCDD_ERR_NO, #LCDD_ERR_NOT_OPENED or /// #LCDD_ERR_INVALID_PARAMETER. // ============================================================================ PRIVATE LCDD_ERR_T lcddp_GetScreenInfo(LCDD_SCREEN_INFO_T* screenInfo) { { screenInfo->width = LCDD_DISP_X; screenInfo->height = LCDD_DISP_Y; screenInfo->bitdepth = LCDD_COLOR_FORMAT_RGB_565; screenInfo->nReserved = 0; return LCDD_ERR_NO; } }
// ============================================================================= // lcddp_Init // ----------------------------------------------------------------------------- /// This function initializes LCD registers after powering on or waking up. // ============================================================================= PRIVATE VOID lcddp_Init(VOID) { //************* Start Initial Sequence **********// /* LCM_WR_REG(0x0001, 0x021c); // set SS and NL bit 0x001c LCM_WR_REG(0x0002, 0x0100); // set 1 line inversion if (g_lcddRotate) { LCM_WR_REG(0x0003, 0x1018); // 0x1030 ? } else { LCM_WR_REG(0x0003, 0x1000); // set GRAM write direction and BGR=1 } */ hal_TimDelay(10 MS_WAITING); //Driving ability setting LCM_WR_REG(0x60,0x00); LCM_WR_REG(0x61,0x06); LCM_WR_REG(0x62,0x00); LCM_WR_REG(0x63,0xC8); LCM_WR_REG(0x73,0x70); //Gamma setting LCM_WR_REG(0x40,0x00); LCM_WR_REG(0x41,0x40); LCM_WR_REG(0x42,0x45); LCM_WR_REG(0x43,0x01); LCM_WR_REG(0x44,0x60); LCM_WR_REG(0x45,0x05); LCM_WR_REG(0x46,0x0c); LCM_WR_REG(0x47,0xd1); LCM_WR_REG(0x48,0x05); LCM_WR_REG(0x50,0x75); LCM_WR_REG(0x51,0x01); LCM_WR_REG(0x52,0x67); LCM_WR_REG(0x53,0x14); LCM_WR_REG(0x54,0xf2); LCM_WR_REG(0x55,0x07); LCM_WR_REG(0x56,0x03); LCM_WR_REG(0x57,0x49); //power voltage setting LCM_WR_REG(0x1f,0x03); //02 LCM_WR_REG(0x20,0x00); LCM_WR_REG(0x24,0x28); //1c 28 LCM_WR_REG(0x25,0x45); //34 45 LCM_WR_REG(0x23,0x2f); //power on LCM_WR_REG(0x18,0x44); LCM_WR_REG(0x21,0x01); LCM_WR_REG(0x01,0x00); LCM_WR_REG(0x1c,0x03); LCM_WR_REG(0x19,0x06); hal_TimDelay(5 MS_WAITING); LCM_WR_REG(0x26,0x84); hal_TimDelay(40 MS_WAITING); LCM_WR_REG(0x26,0xb8); hal_TimDelay(40 MS_WAITING); LCM_WR_REG(0x26,0xbc); // hal_TimDelay(150 MS_WAITING); //GRAM setting LCM_WR_REG(0x02,0x00); LCM_WR_REG(0x03,0x00); LCM_WR_REG(0x04,0x00); LCM_WR_REG(0x05,0xaf); LCM_WR_REG(0x06,0x00); LCM_WR_REG(0x07,0x00); LCM_WR_REG(0x08,0x00); LCM_WR_REG(0x09,0xdb); LCM_WR_REG(0x17,0x05); //16-bit/pixel LCM_WR_CMD(0x0022); }
// ============================================================================ // lcdd_Open // ---------------------------------------------------------------------------- /// Open the LCDD driver. /// It must be called before any call to any other function of this driver. /// This function is to be called only once. /// @return #LCDD_ERR_NO or #LCDD_ERR_DEVICE_NOT_FOUND. // ============================================================================ PUBLIC LCDD_ERR_T lcdd_Open(VOID) { g_lcddConfig = tgt_GetLcddConfig(); hal_LcdcOpen(&g_lcddConfig->config, g_lcddConfig->timings); hal_SysResetOut(FALSE); // Init code LCM_WR_CMD(0x2C); hal_TimDelay(20 MS_WAITING); // MTP Initial Disable LCM_WR_CMD(0xEB); hal_TimDelay(20 MS_WAITING); // Turn ON Oscillator LCM_WR_CMD(0x02); LCM_WR_CMD(0x01); hal_TimDelay(20 MS_WAITING); // DC-DC Select LCM_WR_CMD(0x20); LCM_WR_CMD(0x0A); hal_TimDelay(20 MS_WAITING); // DCDC1 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x01); hal_TimDelay(20 MS_WAITING); // AMP ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x09); hal_TimDelay(20 MS_WAITING); // DCDC2 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x0B); hal_TimDelay(20 MS_WAITING); // DCDC3 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x0F); hal_TimDelay(20 MS_WAITING); // Temperature Compensation set LCM_WR_CMD(0x28); LCM_WR_CMD(0x02); // RAM Skip Area set to no skip LCM_WR_CMD(0x45); LCM_WR_CMD(0x00); // Driver Output mode set LCM_WR_CMD(0x10); LCM_WR_CMD(0x25); // Bias Set LCM_WR_CMD(0x22); LCM_WR_CMD(0x11); // DC/DC Clock Divistion set LCM_WR_CMD(0x24); LCM_WR_CMD(0x11); // Contrast control value (0 to 255) LCM_WR_CMD(0x2A); LCM_WR_CMD(0xBE); // Contrast control for partial display mode LCM_WR_CMD(0x2B); LCM_WR_CMD(0x54); // Set Addressing mode 65k colors LCM_WR_CMD(0x30); LCM_WR_CMD(0x05); // Row Vector mode LCM_WR_CMD(0x32); LCM_WR_CMD(0x0E); // N-block inversion set LCM_WR_CMD(0x34); LCM_WR_CMD(0x92); // Frame Frequency control (High Frame Frequ) LCM_WR_CMD(0x36); LCM_WR_CMD(0x00); // Entry Mode Set (Read Modify Write OFF) LCM_WR_CMD(0x40); LCM_WR_CMD(0x00); // X Area Address set 0 -> 159 (160pix) LCM_WR_CMD(0x42); LCM_WR_CMD(0x00); LCM_WR_CMD(0x9F); // Y Area Address set 4 -> 131 (128pix) LCM_WR_CMD(0x43); LCM_WR_CMD(0x04); LCM_WR_CMD(0x83); // Specified Display Pattern Set (Normal display) LCM_WR_CMD(0x53); LCM_WR_CMD(0x00); // Partial Display Off LCM_WR_CMD(0x55); LCM_WR_CMD(0x00); // Scroll Start Line 0 LCM_WR_CMD(0x5A); LCM_WR_CMD(0x00); // Display On LCM_WR_CMD(0x51); // Allow access g_lcddLock = 1; g_lcddOpened = TRUE; LCDD_TRACE(LCDD_INFO_TRC, 0, "lcdd_Open: LCD Opened"); return LCDD_ERR_NO; }
// ============================================================================= // lcddp_Init // ----------------------------------------------------------------------------- /// This function initializes LCD registers after powering on or waking up. // ============================================================================= PRIVATE VOID lcddp_Init(VOID) { // Init code LCM_WR_CMD_8(0x01); hal_TimDelay(100 MS_WAITING); //--************ Start Initial Sequence **********--// LCM_WR_CMD_8(0x11); //Exit Sleep hal_TimDelay(120 MS_WAITING); LCM_WR_CMD_8(0xB1); LCM_WR_DATA_8(0x01); LCM_WR_DATA_8(0x2C); LCM_WR_DATA_8(0x2D); LCM_WR_CMD_8(0xB2); LCM_WR_DATA_8(0x01); LCM_WR_DATA_8(0x2C); LCM_WR_DATA_8(0x2D); LCM_WR_CMD_8(0xB3); LCM_WR_DATA_8(0x01); LCM_WR_DATA_8(0x2C); LCM_WR_DATA_8(0x2D); LCM_WR_DATA_8(0x01); LCM_WR_DATA_8(0x2C); LCM_WR_DATA_8(0x2D); LCM_WR_CMD_8(0xB4); LCM_WR_DATA_8(0x07); LCM_WR_CMD_8(0xB6); // LCM_WR_DATA_8(0xB4); LCM_WR_DATA_8(0xF0); LCM_WR_CMD_8(0xC0); LCM_WR_DATA_8(0xA2); LCM_WR_DATA_8(0x02); LCM_WR_DATA_8(0x84); LCM_WR_CMD_8(0xC1); LCM_WR_DATA_8(0xC5); LCM_WR_CMD_8(0xC2); LCM_WR_DATA_8(0x0A); LCM_WR_DATA_8(0x00); LCM_WR_CMD_8(0xC3); LCM_WR_DATA_8(0x8A); LCM_WR_DATA_8(0x2A); LCM_WR_CMD_8(0xC4); LCM_WR_DATA_8(0x8A); LCM_WR_DATA_8(0xEE); LCM_WR_CMD_8(0xC5); LCM_WR_DATA_8(0x0E); //VCOM ˮƵڲ //LCM_WR_DATA_8(0x43); //3D LCM_WR_CMD_8(0x36); LCM_WR_DATA_8(0xc8); #if 0 LCM_WR_CMD_8(0xe0);//Set Gamma correction LCM_WR_DATA_8(0x0F); LCM_WR_DATA_8(0x1A); LCM_WR_DATA_8(0x0F); LCM_WR_DATA_8(0x18); LCM_WR_DATA_8(0x2F); LCM_WR_DATA_8(0x28); LCM_WR_DATA_8(0x20); LCM_WR_DATA_8(0x22); LCM_WR_DATA_8(0x1F); LCM_WR_DATA_8(0x1B); LCM_WR_DATA_8(0x23); LCM_WR_DATA_8(0x37); LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0x07); LCM_WR_DATA_8(0x02); LCM_WR_DATA_8(0x10); LCM_WR_CMD_8(0xe1);//Set Gamma correction LCM_WR_DATA_8(0x0F); LCM_WR_DATA_8(0x1B); LCM_WR_DATA_8(0x0F); LCM_WR_DATA_8(0x17); LCM_WR_DATA_8(0x33); LCM_WR_DATA_8(0x2C); LCM_WR_DATA_8(0x29); LCM_WR_DATA_8(0x2E); LCM_WR_DATA_8(0x30); LCM_WR_DATA_8(0x30); LCM_WR_DATA_8(0x39); LCM_WR_DATA_8(0x3F); LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0x07); LCM_WR_DATA_8(0x03); LCM_WR_DATA_8(0x10); #else LCM_WR_CMD_8(0xe0); LCM_WR_DATA_8(0x02); LCM_WR_DATA_8(0x1c); LCM_WR_DATA_8(0x07); LCM_WR_DATA_8(0x12); LCM_WR_DATA_8(0x37); LCM_WR_DATA_8(0x32); LCM_WR_DATA_8(0x29); LCM_WR_DATA_8(0x2d); LCM_WR_DATA_8(0x29); LCM_WR_DATA_8(0x25); LCM_WR_DATA_8(0x2b); LCM_WR_DATA_8(0x39); LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0x01); LCM_WR_DATA_8(0x03); LCM_WR_DATA_8(0x10); LCM_WR_CMD_8(0xe1); LCM_WR_DATA_8(0x03); LCM_WR_DATA_8(0x1d); LCM_WR_DATA_8(0x07); LCM_WR_DATA_8(0x06); LCM_WR_DATA_8(0x2e); LCM_WR_DATA_8(0x2c); LCM_WR_DATA_8(0x29); LCM_WR_DATA_8(0x2d); LCM_WR_DATA_8(0x2e); LCM_WR_DATA_8(0x2e); LCM_WR_DATA_8(0x37); LCM_WR_DATA_8(0x3f); LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0x02); LCM_WR_DATA_8(0x10); #endif LCM_WR_CMD_8(0x3a); //65K mode LCM_WR_DATA_8(0x05); LCM_WR_CMD_8(0x2A); //еַ LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0x02); LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0x81); LCM_WR_CMD_8(0x2B); LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0x21); LCM_WR_DATA_8(0x00); LCM_WR_DATA_8(0xA0); LCM_WR_CMD_8(0x29); hal_TimDelay(120 MS_WAITING); LCM_WR_CMD_8(0x2c); //WRITE ram Data display hal_TimDelay(50 MS_WAITING); }
// ============================================================================ // lcdd_Open // ---------------------------------------------------------------------------- /// Open the LCDD driver. /// It must be called before any call to any other function of this driver. /// This function is to be called only once. /// @return #LCDD_ERR_NO or #LCDD_ERR_DEVICE_NOT_FOUND. // ============================================================================ PUBLIC LCDD_ERR_T lcdd_Open(VOID) { g_lcddConfig = tgt_GetLcddConfig(); g_lcddCsBase = (UINT32) hal_EbcCsOpen(g_lcddConfig->csNum, &g_lcddConfig->csConfig); g_lcddCsOffset = EXP2(g_lcddConfig->rsLine+1); if (0 == g_lcddCsBase) { return LCDD_ERR_DEVICE_NOT_FOUND; } else { // Turn off backlight so that we don't display anything wrong hal_SysResetOut(FALSE); // Standby Mode OFF LCM_WR_CMD(0x2C); hal_TimDelay(20 MS_WAITING); // MTP Initial Disable LCM_WR_CMD(0xEB); hal_TimDelay(20 MS_WAITING); // Turn ON Oscillator LCM_WR_CMD(0x02); LCM_WR_CMD(0x01); hal_TimDelay(20 MS_WAITING); // DC-DC Select LCM_WR_CMD(0x20); LCM_WR_CMD(0x0A); hal_TimDelay(20 MS_WAITING); // DCDC1 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x01); hal_TimDelay(20 MS_WAITING); // AMP ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x09); hal_TimDelay(20 MS_WAITING); // DCDC2 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x0B); hal_TimDelay(20 MS_WAITING); // DCDC3 ON LCM_WR_CMD(0x26); LCM_WR_CMD(0x0F); hal_TimDelay(20 MS_WAITING); // Temperature Compensation set LCM_WR_CMD(0x28); LCM_WR_CMD(0x02); // RAM Skip Area set to no skip LCM_WR_CMD(0x45); LCM_WR_CMD(0x00); // Driver Output mode set LCM_WR_CMD(0x10); LCM_WR_CMD(0x25); // Bias Set LCM_WR_CMD(0x22); LCM_WR_CMD(0x11); // DC/DC Clock Divistion set LCM_WR_CMD(0x24); LCM_WR_CMD(0x11); // Contrast control value (0 to 255) LCM_WR_CMD(0x2A); LCM_WR_CMD(0xBE); // Contrast control for partial display mode LCM_WR_CMD(0x2B); LCM_WR_CMD(0x54); // Set Addressing mode 65k colors LCM_WR_CMD(0x30); LCM_WR_CMD(0x05); // Row Vector mode LCM_WR_CMD(0x32); LCM_WR_CMD(0x0E); // N-block inversion set LCM_WR_CMD(0x34); LCM_WR_CMD(0x92); // Frame Frequency control (High Frame Frequ) LCM_WR_CMD(0x36); LCM_WR_CMD(0x00); // Entry Mode Set (Read Modify Write OFF) LCM_WR_CMD(0x40); LCM_WR_CMD(0x00); // X Area Address set 0 -> 159 (160pix) LCM_WR_CMD(0x42); LCM_WR_CMD(0x00); LCM_WR_CMD(0x9F); // Y Area Address set 4 -> 131 (128pix) LCM_WR_CMD(0x43); LCM_WR_CMD(0x04); LCM_WR_CMD(0x83); // Specified Display Pattern Set (Normal display) LCM_WR_CMD(0x53); LCM_WR_CMD(0x00); // Partial Display Off LCM_WR_CMD(0x55); LCM_WR_CMD(0x00); // Scroll Start Line 0 LCM_WR_CMD(0x5A); LCM_WR_CMD(0x00); // Display On LCM_WR_CMD(0x51); // Allow access g_lcddLock = 1; LCDD_TRACE(LCDD_INFO_TRC, 0, "lcdd_Open: LCD Opened"); return LCDD_ERR_NO; } }
PRIVATE VOID lcddp_Init(VOID) { LCM_WR_CMD(0x01); hal_TimDelay(100 MS_WAITING); main_Write_COM(0x11); //Exit Sleep hal_TimDelay(120 MS_WAITING); main_Write_COM(0xEC); main_Write_DATA(0x0C); main_Write_COM(0x26); //Set Default Gamma main_Write_DATA(0x04); main_Write_COM(0xB1); main_Write_DATA(0x0e); main_Write_DATA(0x14); main_Write_COM(0xC0); //Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD main_Write_DATA(0x06); main_Write_DATA(0x00); main_Write_COM(0xC1); //Set BT[2:0] for AVDD & VCL & VGH & VGL main_Write_DATA(0x02); main_Write_COM(0xC5); //Set VMH[6:0] & VML[6:0] for VOMH & VCOML main_Write_DATA(0x3C); main_Write_DATA(0x40); main_Write_COM(0xC7); main_Write_DATA(0xC3); main_Write_COM(0x3A); //Set Color Format main_Write_DATA(0x55); main_Write_COM(0x2A); //Set Column Address main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x7F); main_Write_COM(0x2B); //Set Page Address main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x00); main_Write_DATA(0x9F); main_Write_COM(0x36); //Set Scanning Direction main_Write_DATA(0xA8); main_Write_COM(0xF2); //Enable Gamma bit main_Write_DATA(0x01); main_Write_COM(0xE0); main_Write_DATA(0x3F);//p1 main_Write_DATA(0x18);//p2 main_Write_DATA(0x18);//p3 main_Write_DATA(0x26);//p4 main_Write_DATA(0x20);//p5 main_Write_DATA(0x0D);//p6 main_Write_DATA(0x46);//p7 main_Write_DATA(0xF3);//p8 main_Write_DATA(0x32);//p9 main_Write_DATA(0x09);//p10 main_Write_DATA(0x02);//p11 main_Write_DATA(0x02);//p12 main_Write_DATA(0x00);//p13 main_Write_DATA(0x00);//p14 main_Write_DATA(0x00);//p15 main_Write_COM(0xE1); main_Write_DATA(0x00);//p1 main_Write_DATA(0x27);//p2 main_Write_DATA(0x27);//p3 main_Write_DATA(0x09);//p4 main_Write_DATA(0x0F);//p5 main_Write_DATA(0x12);//p6 main_Write_DATA(0x39);//p7 main_Write_DATA(0xC0);//p8 main_Write_DATA(0x4D);//p9 main_Write_DATA(0x16);//p10 main_Write_DATA(0x1D);//p11 main_Write_DATA(0x2D);//p12 main_Write_DATA(0x3F);//p13 main_Write_DATA(0x3F);//p14 main_Write_DATA(0x3F);//p15 main_Write_COM(0x29); // Display On LCM_WR_CMD_8(0x2c); //WRITE ram Data display hal_TimDelay(100 MS_WAITING); }