void LCD_Write(uint8_t any) { LPC_GPIO_PORT->PIN[4] &=~(0xFF<<0); LPC_GPIO_PORT->PIN[4] |=(any<<0); LCD_WR_HIGH; // High the WR Signal LCD_WR_LOW; // Low the WR Signal LCD_WR_HIGH; // High the WR Signal // end of Data Sending } void LCD_Send_Cmd(uint8_t Cmd) { LCD_WR_CMD; // CMD Mode LCD_CS_EN; LCD_RD_HIGH; // Enable the Read LCD_Write(Cmd); LCD_RD_LOW; // Disable the Read } void LCD_Send_Data(uint8_t Data) { LCD_WR_DATA; // Data Mode LCD_CS_EN; LCD_RD_HIGH; // Enable the Read LCD_Write(Data); LCD_RD_LOW; // Disable the Read } uint8_t LCD_Read_Data() { uint8_t data; LCD_WR_HIGH; // Enable the WR LCD_RD_LOW; // Low the Read //LCD_Delay(1); LCD_RD_HIGH; // High the Read data= (LPC_GPIO_PORT->PIN[4]>>0 & 0xFF); // Take the Data at the Location //LCD_Delay(2); LCD_WR_LOW; // LOW the WR return data; } void LCD_X_8080_8_WriteM01(unsigned char * pData, int NumBytes) { LCD_WR_DATA; // Data Mode // LCD_PIN_OUT; // Make the D0-D7 Output LCD_CS_EN; LCD_RD_HIGH; //Make High Read //NumBytes= NumBytes/2; for (; NumBytes; NumBytes--) { //LCD_Pause(); LCD_Write(*pData++); } LCD_CS_DS; LCD_RD_LOW; //Make High Read } void LCD_IO_WriteCmd8MultipleData8(uint8_t Cmd, uint8_t *pData, uint32_t Size) { LCD_Send_Cmd(Cmd); while(Size--) { LCD_Send_Data(*pData); pData ++; } } void st7735_Init(void) { LCD_Delay(1); LCD_Send_Cmd(ST7735_SWRESET); LCD_Delay(150); LCD_Send_Cmd(ST7735_SLPOUT); LCD_Delay(200); LCD_IO_WriteCmd8MultipleData8(ST7735_MADCTL, (uint8_t *)"\xA0", 1); // begin left-down corner, end right-up corner // down-up (X-Y exchange, Y-mirror) // refresh top to bottom // RGB, left to right LCD_IO_WriteCmd8MultipleData8(ST7735_COLMOD, (uint8_t *)"\x05", 1); // Interface Pixel Format (16 bit) LCD_IO_WriteCmd8MultipleData8(ST7735_FRMCTR1, (uint8_t *)"\x02\x05\x36", 3); // Frame Rate 80Hz LCD_IO_WriteCmd8MultipleData8(ST7735_FRMCTR2, (uint8_t *)"\x02\x05\x36", 3); // Frame Rate 80Hz LCD_IO_WriteCmd8MultipleData8(ST7735_FRMCTR3, (uint8_t *)"\x02\x05\x36\x02\x05\x36", 6); // Frame Rate 80Hz LCD_IO_WriteCmd8MultipleData8(ST7735_INVCTR, (uint8_t *)"\x07", 1); //Inversion Control LCD_IO_WriteCmd8MultipleData8(ST7735_PWCTR1, (uint8_t *)"\xa2\x02\x84", 3); //Power control LCD_IO_WriteCmd8MultipleData8(ST7735_PWCTR2, (uint8_t *)"\x45", 1); //Power control LCD_IO_WriteCmd8MultipleData8(ST7735_PWCTR3, (uint8_t *)"\x0a\x00", 2); //Power control LCD_IO_WriteCmd8MultipleData8(ST7735_PWCTR4, (uint8_t *)"\x8a\x2a", 2); //Power control LCD_IO_WriteCmd8MultipleData8(ST7735_PWCTR5, (uint8_t *)"\x8a\xee", 2); //Power control LCD_IO_WriteCmd8MultipleData8(ST7735_VMCTR1, (uint8_t *)"\x03", 1); //Power control LCD_IO_WriteCmd8MultipleData8(ST7735_GMCTRP1, (uint8_t *)"x12\x1c\x10\x18\x33\x2c\x25\x28\x28\x27\x2f\x3c\x00\x03\x03\x10", 16); //Gamma controlP LCD_IO_WriteCmd8MultipleData8(ST7735_GMCTRN1, (uint8_t *)"x12\x1c\x10\x18\x2d\x28\x23\x28\x28\x26\x2f\x3d\x00\x03\x03\x10", 16); //Power controlN // Power Control 1 (Vreg1out, Verg2out) // LCD_IO_WriteCmd8MultipleData8(ST7735_PWCTR1, (uint8_t *)"\x17\x15", 2); // // // Power Control 2 (VGH,VGL) // LCD_IO_WriteCmd8MultipleData8(ST7735_PWCTR2, (uint8_t *)"\x41", 1); // // // Power Control 3 (Vcom) // LCD_IO_WriteCmd8MultipleData8(ST7735_VMCTR1, (uint8_t *)"\x00\x12\x80", 3); // // LCD_IO_WriteCmd8MultipleData8(0xB1, (uint8_t *)"\xA0", 1);// Frame rate (60Hz) // LCD_IO_WriteCmd8MultipleData8(0xB4, (uint8_t *)"\x02", 1);// Display Inversion Control (2-dot) // LCD_IO_WriteCmd8MultipleData8(0xB6, (uint8_t *)"\x02\x02", 2); // Display Function Control RGB/MCU Interface Control // LCD_IO_WriteCmd8MultipleData8(0xE9, (uint8_t *)"\x00", 1);// Set Image Functio (Disable 24 bit data) // LCD_IO_WriteCmd8MultipleData8(0xF7, (uint8_t *)"\xA9\x51\x2C\x82", 4);// Adjust Control (D7 stream, loose) // // LCD_Send_Cmd(ST7735_MADCTL); // // LCD_Send_Cmd(ST7735_MAD_DATA_RIGHT_THEN_DOWN); LCD_Send_Cmd(ST7735_DISPON); // Display on LCD_Delay(200); } void LCD_Init_low_level(void) { Chip_SCU_PinMuxSet(0xD, 6, (SCU_MODE_PULLUP | SCU_MODE_FUNC4)); //CS Chip_SCU_PinMuxSet(0xD, 7, (SCU_MODE_PULLUP | SCU_MODE_FUNC4)); //W/R Chip_SCU_PinMuxSet(0xD, 8, (SCU_MODE_PULLUP | SCU_MODE_FUNC4)); //RD Chip_SCU_PinMuxSet(0xD, 9, (SCU_MODE_PULLUP | SCU_MODE_FUNC4)); //RESET Chip_SCU_PinMuxSet(0xD, 10, (SCU_MODE_PULLUP | SCU_MODE_FUNC4)); //D/C Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 6, 20); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 6, 21); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 6, 22); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 6, 23); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 6, 24); /* All LCD Pins as GPIO*/ Chip_SCU_PinMuxSet(0x4, 2, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC0)); //BackLight Chip_SCU_PinMuxSet(0x8, 0, (SCU_MODE_PULLUP | SCU_MODE_FUNC0)); //D0 Chip_SCU_PinMuxSet(0x8, 1, (SCU_MODE_PULLUP | SCU_MODE_FUNC0)); //D1 Chip_SCU_PinMuxSet(0x8, 2, (SCU_MODE_PULLUP | SCU_MODE_FUNC0)); //D2 Chip_SCU_PinMuxSet(0x8, 3, (SCU_MODE_PULLUP | SCU_MODE_FUNC0)); //D3 Chip_SCU_PinMuxSet(0x8, 4, (SCU_MODE_PULLUP | SCU_MODE_FUNC0)); //D4 Chip_SCU_PinMuxSet(0x8, 5, (SCU_MODE_PULLUP | SCU_MODE_FUNC0)); //D5 Chip_SCU_PinMuxSet(0x8, 6, (SCU_MODE_PULLUP | SCU_MODE_FUNC0)); //D6 Chip_SCU_PinMuxSet(0x8, 7, (SCU_MODE_PULLUP | SCU_MODE_FUNC0)); //D7 /* All LCD as Outputs*/ Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 4, 0); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 4, 1); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 4, 2); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 4, 3); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 4, 4); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 4, 5); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 4, 6); Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 4, 7); Chip_GPIO_SetPinState(LPC_GPIO_PORT, 2,2, 1); // Make the LCD Bright LCD_HW_RST(); st7735_Init(); st7735_Clear(); st7735_DrawRGBImage(0,0,127,127,(uint16_t *)MILogo); LCD_Delay(1000); st7735_Clear(); LCD_Delay(50); st7735_DrawRGBImage(20,40,99,49,(uint16_t *)blue2); LCD_Delay(1000); st7735_Clear(); LCD_Delay(50); SetPosition(20, 40); // draw text DrawString((char*)"Initializing..", 0x007b, X2); }