// ***************************************************************************** // void SYSTEM_InitializeBoard(void) // ***************************************************************************** void SYSTEM_InitializeBoard(void) { // --------------------------------------------------------- // Make sure the display DO NOT flicker at start up // --------------------------------------------------------- DisplayBacklightConfig(); DisplayPowerConfig(); DisplayBacklightOff(); // --------------------------------------------------------- // Initialize the Display Driver // --------------------------------------------------------- DRV_GFX_Initialize(); }
void SYSTEM_InitializeBoard(void) { const DRV_SPI_INIT_DATA SPI_Init_Data = {2, 3, 7, 0, SPI_BUS_MODE_3, 0}; // --------------------------------------------------------- // Make sure the display DO NOT flicker at start up // --------------------------------------------------------- DisplayBacklightConfig(); DisplayPowerConfig(); DisplayBacklightOff(); // --------------------------------------------------------- // mikroe Board // SPI-Flash Device pins // --------------------------------------------------------- // chip select pin SST25_CS_TRIS = 0; SST25_CS_LAT = 1; // spi-clock pin SST25_SCK_TRIS = 0; // spi-output pin SST25_SDO_TRIS = 0; // spi-intput pin SST25_SDI_TRIS = 1; /* Config the LED ports to output. */ LEDPortsConfig(); LEDPortsClear(); // --------------------------------------------------------- // Initialize the Display Driver // --------------------------------------------------------- DRV_GFX_Initialize(); DRV_NVM_M25P80_Initialize((DRV_SPI_INIT_DATA*)&SPI_Init_Data); // initialize system tick counter SYSTEM_TickInit(); // initialize the components for Resistive Touch Screen TouchInit(NVMWrite, NVMRead, NVMSectorErase, NULL); // TouchInit(NULL, NULL, NULL, NULL); }
// ***************************************************************************** // void SYSTEM_InitializeBoard(void) // ***************************************************************************** void SYSTEM_InitializeBoard(void) { // SPI initialization for Serial RAM const DRV_SPI_INIT_DATA SRAM_SPI_Init_Data = { 2, 3, 7, 1, SPI_BUS_MODE_1, 0}; // SPI initialization for EPD const DRV_SPI_INIT_DATA EPD_SPI_Init_Data = { 1, 3, 7, 1, SPI_BUS_MODE_1, 0}; // --------------------------------------------------------- // Make sure the display DO NOT flicker at start up // --------------------------------------------------------- DisplayBacklightConfig(); DisplayPowerConfig(); DisplayBacklightOff(); // --------------------------------------------------------- // ADC Explorer 16 Development Board Errata (work around 2) // RB15 should be output // --------------------------------------------------------- LATBbits.LATB15 = 0; TRISBbits.TRISB15 = 0; // --------------------------------------------------------- // EPD PicTail Plus Daughter Board 23K256 // SPI-RAM Device Chip Select pin // --------------------------------------------------------- MCHP_23K256_CS_TRIS = 0; MCHP_23K256_CS_LAT = 1; // --------------------------------------------------------- // EPD PicTail Plus Daughter // Board EPD Controller Device Chip Select pin // --------------------------------------------------------- DRV_EPD_SPI_CS_TRIS = 0; DRV_EPD_SPI_CS_LAT = 1; // --------------------------------------------------------- // SPI Port pins // --------------------------------------------------------- // spi-clock pin TRISFbits.TRISF6 = 0; // spi-output pin TRISFbits.TRISF8 = 0; // spi-intput pin TRISFbits.TRISF7 = 1; // initialize SPI driver DRV_RAM_23K256_Initialize((DRV_SPI_INIT_DATA*)&SRAM_SPI_Init_Data); // initialize EPD driver DRV_EPD_SPI_Initialize((DRV_SPI_INIT_DATA*)&EPD_SPI_Init_Data); // Initialize the e-paper (EPD) EPD_display_init(); // --------------------------------------------------------- // Initialize the Display Driver // --------------------------------------------------------- DRV_GFX_Initialize(); GFX_Initialize(); // Initialize the reference timer. SYSTEM_TickInit(); }
/********************************************************************* * 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); }
// ***************************************************************************** void SYSTEM_InitializeBoard(void) { const DRV_SPI_INIT_DATA SPI_Init_Data = {2, 3, 7, 0, SPI_BUS_MODE_3, 0}; // --------------------------------------------------------- // Make sure the display DO NOT flicker at start up // --------------------------------------------------------- DisplayBacklightConfig(); DisplayPowerConfig(); DisplayBacklightOff(); // --------------------------------------------------------- // ADC Explorer 16 Development Board Errata (work around 2) // RB15 should be output // --------------------------------------------------------- LATBbits.LATB15 = 0; TRISBbits.TRISB15 = 0; // --------------------------------------------------------- // Explorer 16 Development Board MCHP25LC256 chip select signal, // even if not used must be driven to high so it does not // interfere with other SPI peripherals that uses the same SPI signals. // --------------------------------------------------------- TRISDbits.TRISD12 = 0; LATDbits.LATD12 = 1; // --------------------------------------------------------- // Graphics LCD Controller PICtail Plus SSD1926 Board // SPI-Flash Device pins // --------------------------------------------------------- // chip select pin TRISDbits.TRISD1 = 0; LATDbits.LATD1 = 1; // spi-clock pin TRISGbits.TRISG6 = 0; // spi-output pin TRISGbits.TRISG8 = 0; // spi-intput pin TRISGbits.TRISG7 = 1; // --------------------------------------------------------- // UART pins // --------------------------------------------------------- // initialize the UART pins TRISFbits.TRISF5 = 0; TRISFbits.TRISF4 = 1; // unlock PPS __builtin_write_OSCCONL(OSCCON & 0xbf); // set UART pins RPINR19bits.U2RXR = 10; // assign RP10 to RX RPOR8bits.RP17R = 5; // assign RP17 to TX // set SPI pins RPOR10bits.RP21R = 11; // assign RP21 for SCK2 RPOR9bits.RP19R = 10; // assign RP19 for SDO2 RPINR22bits.SDI2R = 26; // assign RP26 for SDI2 // lock PPS __builtin_write_OSCCONL(OSCCON | 0x40); // --------------------------------------------------------- // Initialize the Display Driver // --------------------------------------------------------- DRV_GFX_Initialize(); DRV_NVM_SST25VF016_Initialize((DRV_SPI_INIT_DATA*)&SPI_Init_Data); // initialize system tick counter SYSTEM_TickInit(); // initialize the components for Resistive Touch Screen TouchInit(NVMWrite, NVMRead, NVMSectorErase, NULL); }