void InitApp(void) { /* Setup analog functionality and port direction */ // enable multi-vector interrupts INTEnableSystemMultiVectoredInt(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // STEP 2. configure Timer 1 using internal clock, 1:256 prescale OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_1, T1_TICK); // set up the timer interrupt with a priority of 2 ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2); /* Zero to DELAY_COUNTER for Delay procedure. */ StartTimer(); /* Initialize peripherals */ DisplayBacklightConfig(); //#if defined WANT_GOL_INIT GOLInit(); //#endif // TouchInit(NULL,NULL,NULL,NULL); DisplayBacklightOn(); SPIFlashInit(); // initialize the components for Resistive Touch Screen //#if defined WANT_TOUCH_INIT // TouchInit(NULL,NULL,NULL,NULL); //#endif // SDCARDInit(); // MP3Init(); /* PORT Init */ /* PORTD 0-3 bits inputs. */ /* PORTA 0-1 bits outputs. */ /* TODO Must be disable the JTAG port, that we are to appropriate using */ /* RA0, and RA1 ports. */ DDPCONbits.JTAGEN = 0; /* JTAG debug disabled */ /* TODO D port output now !!!! */ TRISDbits.TRISD14 = TRISDbits.TRISD15 = 0; /* Port D 14, 15, pins pull up resistor enabled */ // CNPUEbits.CNPUE20 = CNPUEbits.CNPUE21 = 1; TRISAbits.TRISA0 = TRISAbits.TRISA1 = 0; }
void SYS_Initialize ( void* data ) { uint8_t handle=0xff; //Handle to the driver // populate the PMP init configuration structure init.polarity.addressLatchPolarity = PMP_POLARITY_ACTIVE_HIGH; init.polarity.rwStrobePolarity = PMP_POLARITY_ACTIVE_LOW; init.polarity.writeEnableStrobePolarity = PMP_POLARITY_ACTIVE_LOW; init.polarity.chipselect1Polarity = PMP_POLARITY_ACTIVE_HIGH; init.polarity.chipselect2Polarity = PMP_POLARITY_ACTIVE_LOW; init.ports.readWriteStrobe = PORT_ENABLE; init.ports.writeEnableStrobe = PORT_ENABLE; init.moduleInit.value = SYS_MODULE_POWER_RUN_FULL; init.pmpID = PMP_ID_0; init.stopInIdle = false; init.muxMode = PMP_MUX_NONE; object = DRV_PMP_Initialize (DRV_PMP_INDEX_0, (SYS_MODULE_INIT *)&init); /* Initialize the Application */ APP_Initialize(); /* Initializethe interrupt system */ SYS_INT_Initialize(); SYS_INT_VectorPrioritySet(INT_VECTOR_T4, INT_PRIORITY_LEVEL2); /* set priority for PMP interrupt source */ SYS_INT_VectorPrioritySet(INT_VECTOR_PMP, INT_PRIORITY_LEVEL6); /* Initialize the global interrupts */ SYS_INT_Enable(); GFX_DRV_lcc_Initialize(0); //Initialize the Graphics Driver while( handle != 0) { handle = GFX_DRV_lcc_Open(0); } GFX_Initialize(); /* Turn on the backlight */ DisplayBacklightOn(); /* Initialize the BSP */ // BSP_Initialize( ); }
/********************************************************************* * Function: void DisplayBrightness(WORD level) * * PreCondition: none * * Input: level - Brightness level. Valid values are 0 to 100. * - 0: brightness level is zero or display is turned off * - 1: brightness level is maximum * * Output: none * * Side Effects: none * * Overview: Sets the brightness of the display. * * Note: none * ********************************************************************/ void DisplayBrightness(WORD level) { // If the brightness can be controlled (for example through PWM) // add code that will control the PWM here. if (level > 0) { DisplayBacklightOn(); } else if (level == 0) { DisplayBacklightOff(); } }
void ResetDevice() { /* SetLCDPorts(); Init_MCU();*/ // Initialize the device DriverInterfaceInit(); DelayMs(1); // Delay to let controller ready for next SetReg command /* LCD_nRESET = 1; DelayMs(1); // Delay 1ms LCD_nRESET = 0; DelayMs(10); // Delay 10ms // This delay time is necessary LCD_nRESET = 1; DelayMs(120); // Delay 120 ms*/ ResetLCD(); LCD_ILI9341_CMD(PowerControlB); //Power control B (CFh) LCD_ILI9341_Parameter(0x00); LCD_ILI9341_Parameter(0x81); LCD_ILI9341_Parameter(0X30); LCD_ILI9341_CMD(PowerOnSequenceControl); LCD_ILI9341_Parameter(0x64); LCD_ILI9341_Parameter(0x03); LCD_ILI9341_Parameter(0X12); LCD_ILI9341_Parameter(0X81); LCD_ILI9341_CMD(DriverTimingControlA); LCD_ILI9341_Parameter(0x85); LCD_ILI9341_Parameter(0x10); LCD_ILI9341_Parameter(0x78); LCD_ILI9341_CMD(PowerControlA); LCD_ILI9341_Parameter(0x39); LCD_ILI9341_Parameter(0x2C); LCD_ILI9341_Parameter(0x00); LCD_ILI9341_Parameter(0x34); LCD_ILI9341_Parameter(0x02); LCD_ILI9341_CMD(PumpRatioControl); LCD_ILI9341_Parameter(0x20); LCD_ILI9341_CMD(DriverTimingControlB); LCD_ILI9341_Parameter(0x00); LCD_ILI9341_Parameter(0x00); LCD_ILI9341_CMD(FrameRateControlInNormalModeFullColors); LCD_ILI9341_Parameter(0x00); LCD_ILI9341_Parameter(0x1B); LCD_ILI9341_CMD(DisplayFunctionControl); // Display Function Control LCD_ILI9341_Parameter(0x0A); LCD_ILI9341_Parameter(0xA2); LCD_ILI9341_CMD(PowerControl1); //Power control LCD_ILI9341_Parameter(0x21); //VRH[5:0] LCD_ILI9341_CMD(PowerControl2); //Power control LCD_ILI9341_Parameter(0x11); //SAP[2:0];BT[3:0] LCD_ILI9341_CMD(VCOMControl1); //VCM control LCD_ILI9341_Parameter(0x3F); LCD_ILI9341_Parameter(0x3C); LCD_ILI9341_CMD(VCOMControl2); //VCM control2 LCD_ILI9341_Parameter(0Xb5); LCD_ILI9341_CMD(PixelFormatSet); #if defined (_64K_COLOR_MODE) LCD_ILI9341_Parameter(BITPERPIXEL16); #elif defined (_256K_COLOR_MODE) LCD_ILI9341_Parameter(BITPERPIXEL18); #endif LCD_ILI9341_CMD(MemoryAccessControl); // Memory Access Control LCD_ILI9341_Parameter(RGBSET | MVSET | MXSET); LCD_ILI9341_CMD(InterfaceControl); // Memory Access Control LCD_ILI9341_Parameter(0x01); #if defined (_MDT00) LCD_ILI9341_Parameter(MDT00); #elif defined (_MDT01) LCD_ILI9341_Parameter(MDT01); #else #error "You must define the MDT parameter !" #endif LCD_ILI9341_Parameter(0x00); LCD_ILI9341_CMD(Enable3G); // 3Gamma Function Disable LCD_ILI9341_Parameter(0x00); LCD_ILI9341_CMD(GammaSet); //Gamma curve selected LCD_ILI9341_Parameter(0x01); LCD_ILI9341_CMD(PositiveGammaCorrection); //Set Gamma LCD_ILI9341_Parameter(0x0F); LCD_ILI9341_Parameter(0x26); LCD_ILI9341_Parameter(0x24); LCD_ILI9341_Parameter(0x0B); LCD_ILI9341_Parameter(0x0E); LCD_ILI9341_Parameter(0x09); LCD_ILI9341_Parameter(0x54); LCD_ILI9341_Parameter(0XA8); LCD_ILI9341_Parameter(0x46); LCD_ILI9341_Parameter(0x0C); LCD_ILI9341_Parameter(0x17); LCD_ILI9341_Parameter(0x09); LCD_ILI9341_Parameter(0x0F); LCD_ILI9341_Parameter(0x07); LCD_ILI9341_Parameter(0x00); LCD_ILI9341_CMD(NegativeGammaCorrection); //Set Gamma LCD_ILI9341_Parameter(0x00); LCD_ILI9341_Parameter(0x19); LCD_ILI9341_Parameter(0x1B); LCD_ILI9341_Parameter(0x04); LCD_ILI9341_Parameter(0x10); LCD_ILI9341_Parameter(0x07); LCD_ILI9341_Parameter(0x2A); LCD_ILI9341_Parameter(0x47); LCD_ILI9341_Parameter(0x39); LCD_ILI9341_Parameter(0x03); LCD_ILI9341_Parameter(0x06); LCD_ILI9341_Parameter(0x06); LCD_ILI9341_Parameter(0x30); LCD_ILI9341_Parameter(0x38); LCD_ILI9341_Parameter(0x0F); //lcdSetWindow(10, 230 - 1, 10, 310 - 1); LCD_ILI9341_CMD(SleepOut); //Exit Sleep DelayMs(120); //delayms(120); LCD_ILI9341_CMD(0x29); //Display on DisplayBacklightOn(); }