Dear all,
I was trying to configure and initialize ILI9341 display controller with 240 X 320 Pixels of Color TFT display using the TM4C123 and the program has worked perfect. However, after checking a sample prototype software, I tried to create individual header called LCD2_2SPI.h and an associated c file named: LCD2_2SPI.c . After doing this, I have included the header file in the main program given below:
Now the problem is that, when the functions TivaInit(); Lcd_Init(); LCD_Clear(BLACK); (highlighted below in light blue) was directly defined inside this main.c file, there were no compilation error. However, when I created a header and shifted the definitions and declared the functions in the header and defined them in LCD2_2SPI.c , there are errors coming (compilation errors) saying: #10234-D unresolved symbols remain in these three functions. The Problems window is screenshot below:
Please help as to what might be going wrong. I have tried a lot checking everything. I am using TivaWare_C_Series-2.1.1.71 and the configurations in CCS project and libraries are fine. The project runs successfully when the functions are defined in main.c and declared in main.c But errors show up when moved to the header LCD2_2SPI.h and an associated c file named: LCD2_2SPI.c
SOFTWARE:
// Include Files
#include <stdint.h>
#include <stdbool.h>
#include "driverlib/LCD2_2SPI.h" // (this was created later on after checking everything in this main file)
#include "driverlib/ssi.h"
#include "driverlib/gpio.h"
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/interrupt.h"
#include "inc/hw_gpio.h"
//Constants //
//const unsigned int black = 0;
//const unsigned int Red = 63488;
//const unsigned int Green = 2016;
//const unsigned int Blue = 31;
//const unsigned int White = 65535;
//const unsigned int Purple = 61727;
//const unsigned int Yellow = 65504;
//const unsigned int Cyan = 2047;
//const unsigned int d_gray = 21130;
//const unsigned int l_gray = 31727;
//
//Definitions //
unsigned int BACK_COLOR, POINT_COLOR; //Background color, brush color
////////////////// Interrupt Dummy ///////////////////////////////////////////////////////////////
void UartIntHandler(void)
{
}
void Uart2IntHandler(void)
{
}
/////////////////////// Fns //////////////////////////////////////////////////////////////////////
////////////////// Main Routine ////////////////////////////////////////////////////////////////////
void main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_2 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysFreq = SysCtlClockGet();
TivaInit();
Lcd_Init();
LCD_Clear(BLACK);
BACK_COLOR=BLUE;
POINT_COLOR=WHITE;
// LCD_ShowString(10,10,TEST);//LCD_ShowString(u16 x,u16 y,const u8 *p)
// Draw_Circle(100,100,50);
// LCD_ShowNum(100,100,123,5);//LCD_Show2Num(u16 x,u16 y,u16 num,u8 len)
// LCD_Show2Num(100,200,123,5);//LCD_Show2Num(u16 x,u16 y,u16 num,u8 len)
// LCD_DrawRectangle(1,1,240,30);//LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2)
// LCD_Fill(0,0,240,30,WHITE);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
// LCD_Fill(1,1,239,29,YELLOW);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
// LCD_Fill(2,2,238,28,CYAN);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
// LCD_Fill(3,3,237,27,BLUE);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
//
// LCD_Fill(180,11,183,27,WHITE);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
// LCD_Fill(185,14,188,27,WHITE);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
// LCD_Fill(190,17,193,27,WHITE);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
// LCD_Fill(195,20,198,27,WHITE);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
// LCD_Fill(200,23,203,27,WHITE);//LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
while(1)
{
// u16 circx=120,circy=0;
// LCD_ShowString(220,4,"R");
// SysCtlDelay(SysFreq);
// LCD_ShowString(220,4," ");
// SysCtlDelay(SysFreq);
// while(circy<321)
// {
// POINT_COLOR=WHITE;
// Draw_Circle(circx,circy,50);//Draw_Circle(u16 x0,u16 y0,u8 r)
// POINT_COLOR=BLACK;
// Draw_Circle(circx,circy,50);//Draw_Circle(u16 x0,u16 y0,u8 r)
// circy++;
// }
}
}
_______________________________________________________________________________________________________________________________
THE HEADER FILE LCD2_2SPI.h:
#include <stdint.h>
#include <stdbool.h>
#ifndef __LCD_H
#define __LCD_H
// Define the size of the LCD
#define LCD_W 240
#define LCD_H 320
#define AllPins GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
#define TFTControlPins GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
#define TFTReset GPIO_PIN_4
#define LPLEDs GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
#define u8 unsigned char
#define u16 unsigned int
#define u32 unsigned long
#define MSB GPIO_PORTB_BASE
#define LSB GPIO_PORTD_BASE
// SSI RELATED DEFINITIONS, ONLY FOR 2.2" LCD //
#define SCK GPIO_PIN_2//PORT A, SSI 0 ONLY
#define CS GPIO_PIN_3
#define MISO GPIO_PIN_4
#define MOSI GPIO_PIN_5
#define DC GPIO_PIN_4// PORT E
#define RESET GPIO_PIN_5// PORT E
#define LCD_RS GPIO_PIN_4
#define LCD_WR GPIO_PIN_5
#define LCD_RD GPIO_PIN_6
#define LCD_CS GPIO_PIN_7
#define LCD_REST GPIO_PIN_4
// Temporary values
u16 temp=0x0000;
u8 TEST[]="Hello! This is a testing routine that displays the data on the LCD";
// Defined Arrays //
//unsigned char symbol[];
//unsigned char asc2_1608[1520];
u8 symbol[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0xFE,0xFF,0x01,0x00,0xFE,0xFF,0x01,0x00,0x06,0xC0,0x00,0x00,0x06,0xC0,0x00,0x00,0x06,0xC0,0x00,0x00,0xFE,0xFF,0x00,0x00,0x06,0xC0,0x00,0x00,0x06,0xC0,0x00,0x00,0x06,0xC0,0x00,0x00,0xFE,0xFF,0x00,0x00,0x06,0xC0,0x00,0x00,0x06,0xC0,0x00,0x00,0x02,0x00,0x00,0x30,0x30,0x0C,0x1C,0xF0,0x7F,0xFC,0x3F,0x30,0x30,0x0C,0x1C,0x30,0x30,0x0C,0x1C,0x30,0x30,0x0C,0x1C,0x30,0x30,0x0C,0x1C,0xF0,0x3F,0xFC,0x1F,0x30,0x30,0x0C,0x1C,0x30,0x30,0x0C,0x1C,0x30,0x30,0x0C,0x1C,0x30,0x30,0x0C,0x1C,0xF0,0x3F,0xFC,0x1F,0xF0,0x3F,0xFC,0x1F,0x30,0x30,0x0C,0x1C,0x30,0x10,0x04,0x0C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x08,0x08,0xC0,0xF1,0xFF,0x1F,0xC0,0xF0,0xFF,0x1F,0xC0,0x48,0x4C,0x1C,0xC4,0xDC,0xCC,0x1D,0xCC,0xDC,0x8D,0x1D,0xDC,0x8E,0x8D,0x1D,0xD8,0x06,0x0E,0x1F,0xF8,0xC3,0xEF,0x1D,0xF8,0xF1,0xEC,0x1C,0xD0,0x60,0x1D,0x1C,0xC0,0x1C,0x77,0x0C,0xFE,0x9F,0xE7,0x00,0x34,0x83,0xE3,0x0C,0x30,0xC3,0xFF,0x1F,0x30,0xC3,0x61,0x00,0x30,0xE3,0x61,0x00,0x30,0xE3,0x61,0x06,0x30,0xF3,0xFF,0x0F,0x30,0xDB,0x61,0x00,0x30,0xFB,0x61,0x04,0x38,0xDB,0x61,0x0E,0x18,0xCF,0xFF,0x0F,0x18,0xC7,0x61,0x00,0x98,0xC7,0x61,0x00,0x0C,0xC3,0x61,0x38,0x04,0xC2,0xFF,0x3F,0x06,0xC0,0x01,0x00,0x02,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,
};
u8 asc2_1608[1520]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
0x00,0x48,0x6C,0x24,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x24,0x24,0x24,0x7F,0x12,0x12,0x12,0x7F,0x12,0x12,0x12,0x00,0x00,
0x00,0x00,0x08,0x1C,0x2A,0x2A,0x0A,0x0C,0x18,0x28,0x28,0x2A,0x2A,0x1C,0x08,0x08,
0x00,0x00,0x00,0x22,0x25,0x15,0x15,0x15,0x2A,0x58,0x54,0x54,0x54,0x22,0x00,0x00,
0x00,0x00,0x00,0x0C,0x12,0x12,0x12,0x0A,0x76,0x25,0x29,0x11,0x91,0x6E,0x00,0x00,
0x00,0x06,0x06,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00,
0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00,
0x00,0x00,0x00,0x00,0x08,0x08,0x6B,0x1C,0x1C,0x6B,0x08,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x7F,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x04,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00,
0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00,
0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00,
0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00,
0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,
0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x04,
0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00,
0x00,0x00,0x00,0x3C,0x42,0x42,0x46,0x40,0x20,0x10,0x10,0x00,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x1C,0x22,0x5A,0x55,0x55,0x55,0x55,0x2D,0x42,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x08,0x08,0x18,0x14,0x14,0x24,0x3C,0x22,0x42,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x1E,0x22,0x42,0x42,0x42,0x22,0x1F,0x00,0x00,
0x00,0x00,0x00,0x7C,0x42,0x42,0x01,0x01,0x01,0x01,0x01,0x42,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x1F,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1F,0x00,0x00,
0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x42,0x42,0x3F,0x00,0x00,
0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x02,0x02,0x07,0x00,0x00,
0x00,0x00,0x00,0x3C,0x22,0x22,0x01,0x01,0x01,0x71,0x21,0x22,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x0F,
0x00,0x00,0x00,0x77,0x22,0x12,0x0A,0x0E,0x0A,0x12,0x12,0x22,0x22,0x77,0x00,0x00,
0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x7F,0x00,0x00,
0x00,0x00,0x00,0x77,0x36,0x36,0x36,0x36,0x2A,0x2A,0x2A,0x2A,0x2A,0x6B,0x00,0x00,
0x00,0x00,0x00,0xE3,0x46,0x46,0x4A,0x4A,0x52,0x52,0x52,0x62,0x62,0x47,0x00,0x00,
0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x3E,0x02,0x02,0x02,0x02,0x07,0x00,0x00,
0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x4D,0x53,0x32,0x1C,0x60,0x00,
0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x3E,0x12,0x12,0x22,0x22,0x42,0xC7,0x00,0x00,
0x00,0x00,0x00,0x7C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x42,0x42,0x3E,0x00,0x00,
0x00,0x00,0x00,0x7F,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,
0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,
0x00,0x00,0x00,0xE7,0x42,0x42,0x22,0x24,0x24,0x14,0x14,0x18,0x08,0x08,0x00,0x00,
0x00,0x00,0x00,0x6B,0x49,0x49,0x49,0x49,0x55,0x55,0x36,0x22,0x22,0x22,0x00,0x00,
0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,
0x00,0x00,0x00,0x7E,0x21,0x20,0x10,0x10,0x08,0x04,0x04,0x42,0x42,0x3F,0x00,0x00,
0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00,
0x00,0x00,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x40,
0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00,
0x00,0x38,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x78,0x44,0x42,0x42,0xFC,0x00,0x00,
0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x26,0x1A,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x02,0x02,0x02,0x44,0x38,0x00,0x00,
0x00,0x00,0x00,0x60,0x40,0x40,0x40,0x78,0x44,0x42,0x42,0x42,0x64,0xD8,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x02,0x02,0x42,0x3C,0x00,0x00,
0x00,0x00,0x00,0xF0,0x88,0x08,0x08,0x7E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x22,0x22,0x1C,0x02,0x3C,0x42,0x42,0x3C,
0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x3A,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x1E,
0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x72,0x12,0x0A,0x16,0x12,0x22,0x77,0x00,0x00,
0x00,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x92,0x92,0x92,0x92,0x92,0xB7,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3B,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x26,0x42,0x42,0x42,0x22,0x1E,0x02,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x44,0x42,0x42,0x42,0x44,0x78,0x40,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x4C,0x04,0x04,0x04,0x04,0x1F,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x42,0x02,0x3C,0x40,0x42,0x3E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x3E,0x08,0x08,0x08,0x08,0x08,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x42,0x42,0x42,0x42,0x62,0xDC,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x08,0x08,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEB,0x49,0x49,0x55,0x55,0x22,0x22,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x24,0x18,0x18,0x18,0x24,0x6E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x18,0x08,0x08,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x22,0x10,0x08,0x08,0x44,0x7E,0x00,0x00,
0x00,0xC0,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x20,0x20,0xC0,0x00,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x00,0x06,0x08,0x08,0x08,0x08,0x08,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x06,0x00,
0x0C,0x32,0xC2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
// Variables //
uint32_t SysFreq;
int32_t LCD_READ, read_data=0;
unsigned char bitdata;
uint32_t reply[];
static u16 kkk=1 , kkkbk=0;
extern u16 BACK_COLOR, POINT_COLOR;
extern void TivaInit(void);
extern void Lcd_Init(void);
extern void LCD_Clear(u16 Color);
extern void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);
extern void LCD_WR_DATA8(char da);
extern void LCD_WR_DATA(int da);
extern void LCD_WR_REG(char da);
extern void LCD_DrawPoint(u16 x,u16 y);
extern void LCD_DrawPoint_big(u16 x,u16 y);
u16 LCD_ReadPoint(u16 x,u16 y);
extern void Draw_Circle(u16 x0,u16 y0,u8 r);
extern void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2);
extern void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2);
extern void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
extern void LCD_ShowChar(u16 x,u16 y,u8 num,u8 mode);
extern void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len);
extern void LCD_Show2Num(u16 x,u16 y,u16 num,u8 len);
extern void LCD_ShowString(u16 x,u16 y,const u8 *p);
//Pen color
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40 //Brown
#define BRRED 0XFC07 //Brownish red
#define GRAY 0X8430 //Gray
//GUI Color
#define DARKBLUE 0X01CF //Navy blue
#define LIGHTBLUE 0X7D7C //Light Blue
#define GRAYBLUE 0X5458 //Gray-blue
// More than three colors for color PANEL
#define LIGHTGREEN 0X841F //Light green
#define LGRAY 0XC618 //Light gray (PANNEL), form the background color
#define LGRAYBLUE 0XA651 //Light gray blue (intermediate layer color)
#define LBBLUE 0X2B12 //Blue light brown (select entry inverse)
#endif
____________________________________________________________________________________________________________
THE LCD2_2SPI.c :
#include <stdint.h>
#include <stdbool.h>
#include "driverlib/ssi.h"
#include "driverlib/gpio.h"
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/interrupt.h"
#include "driverlib/LCD2_2SPI.h"
#include "inc/hw_gpio.h"
void LCD_Writ_Bus(char da) //Parallel Data Write function
{
bitdata=da;
/* LCD_SDI=bit7;LCD_SCK=0;LCD_SCK=1;
LCD_SDI=bit6;LCD_SCK=0;LCD_SCK=1;
LCD_SDI=bit5;LCD_SCK=0;LCD_SCK=1;
LCD_SDI=bit4;LCD_SCK=0;LCD_SCK=1;
LCD_SDI=bit3;LCD_SCK=0;LCD_SCK=1;
LCD_SDI=bit2;LCD_SCK=0;LCD_SCK=1;
LCD_SDI=bit1;LCD_SCK=0;LCD_SCK=1;
LCD_SDI=bit0;LCD_SCK=0;LCD_SCK=1;
*/
SSIDataPut(SSI0_BASE,bitdata);
while(SSIBusy(SSI0_BASE));
}
void LCD_WR_DATA8_SSI(char da) //Send -8 bit parameter data // CONVERTED TO CCS
{
//DC=1;
GPIOPinWrite(GPIO_PORTE_BASE, DC,0x10); //Pulses the dc line
LCD_Writ_Bus(da);
}
void LCD_WR_DATA(int da) // CONVERTED TO CCS
{
//DC=1;
GPIOPinWrite(GPIO_PORTE_BASE, DC,0x10); //Pulses the dc line
LCD_Writ_Bus(da>>8);
LCD_Writ_Bus(da);
}
void LCD_WR_REG(int da) // CONVERTED TO CCS
{
//DC=0;
GPIOPinWrite(GPIO_PORTE_BASE, DC,0); //Pulses the WR line
LCD_Writ_Bus(da);
}
// void LCD_WR_REG_DATA(int reg,int da) // CONVERTED TO CCS
//{
// LCD_WR_REG(reg);
// LCD_WR_DATA(da);
//}
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2) // CONVERTED TO CCS
{
LCD_WR_REG(0x2a);
LCD_WR_DATA8_SSI(x1>>8);
LCD_WR_DATA8_SSI(x1);
LCD_WR_DATA8_SSI(x2>>8);
LCD_WR_DATA8_SSI(x2);
LCD_WR_REG(0x2b);
LCD_WR_DATA8_SSI(y1>>8);
LCD_WR_DATA8_SSI(y1);
LCD_WR_DATA8_SSI(y2>>8);
LCD_WR_DATA8_SSI(y2);
LCD_WR_REG(0x2C);
}
///////////////////////////newly imported///////////////////////////////
// void Write_Command(unsigned int Wcommand)
// {
//// TFT_RD = 1;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_RD,LCD_RD);
//// TFT_RS = 0;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_RS,LCD_RS);
//// TFT_DP_Hi = wcommand >> 8;
// GPIOPinWrite(MSB, AllPins,(Wcommand >>8));
//// TFT_DP_Lo = wcommand ;
// GPIOPinWrite(LSB, AllPins,Wcommand);
// // TFT_WR = 0;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_WR,0);
// // TFT_WR = 1 ;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_WR,LCD_WR);
// }
//
// void Write_Data(unsigned int Wdata)
// {
//// TFT_RD = 1;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_RD,LCD_RD);
//// TFT_RS = 1 ;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_RS,LCD_RS);
//// TFT_DP_Hi = Wdata >>8 ;
// GPIOPinWrite(MSB, AllPins,(Wdata >>8));
//// TFT_DP_Lo = wdata;
// GPIOPinWrite(LSB, AllPins,Wdata);
//// TFT_WR = 0;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_WR,0);
//// TFT_WR = 1 ;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_WR,LCD_WR);
//
// }
// void Write_Command_Data(unsigned int Wcommand,unsigned int Wdata)
// {
// Write_Command(Wcommand);
// Write_Data(Wdata);
// }
void Lcd_Init(void)
{
GPIOPinWrite(GPIO_PORTA_BASE, CS,CS);
//TFT_RST=1;
GPIOPinWrite(GPIO_PORTE_BASE, RESET,0x20);
//delay_ms(5);
SysCtlDelay(SysFreq/2);// 5 ms delay
//TFT_RST=0;
GPIOPinWrite(GPIO_PORTE_BASE, RESET,0);
//delay_ms(15);
SysCtlDelay(SysFreq/2);// 15 ms delay
//TFT_RST=1;
GPIOPinWrite(GPIO_PORTE_BASE, RESET,0x20);
//delay_ms(15);
SysCtlDelay(SysFreq/2);// 15 ms delay
//TFT_CS =0;
GPIOPinWrite(GPIO_PORTA_BASE, CS,0x08);
SysCtlDelay(SysFreq/100);// 15 ms delay
GPIOPinWrite(GPIO_PORTA_BASE, CS,0);
LCD_WR_REG(0xCB);
LCD_WR_DATA8_SSI(0x39);
LCD_WR_DATA8_SSI(0x2C);
LCD_WR_DATA8_SSI(0x00);
LCD_WR_DATA8_SSI(0x34);
LCD_WR_DATA8_SSI(0x02);
LCD_WR_REG(0xCF);
LCD_WR_DATA8_SSI(0x00);
LCD_WR_DATA8_SSI(0XC1);
LCD_WR_DATA8_SSI(0X30);
LCD_WR_REG(0xE8);
LCD_WR_DATA8_SSI(0x85);
LCD_WR_DATA8_SSI(0x00);
LCD_WR_DATA8_SSI(0x78);
LCD_WR_REG(0xEA);
LCD_WR_DATA8_SSI(0x00);
LCD_WR_DATA8_SSI(0x00);
LCD_WR_REG(0xED);
LCD_WR_DATA8_SSI(0x64);
LCD_WR_DATA8_SSI(0x03);
LCD_WR_DATA8_SSI(0X12);
LCD_WR_DATA8_SSI(0X81);
LCD_WR_REG(0xF7);
LCD_WR_DATA8_SSI(0x20);
LCD_WR_REG(0xC0); //Power control
LCD_WR_DATA8_SSI(0x23); //VRH[5:0]
LCD_WR_REG(0xC1); //Power control
LCD_WR_DATA8_SSI(0x10); //SAP[2:0];BT[3:0]
LCD_WR_REG(0xC5); //VCM control
LCD_WR_DATA8_SSI(0x3e);
LCD_WR_DATA8_SSI(0x28);
LCD_WR_REG(0xC7); //VCM control2
LCD_WR_DATA8_SSI(0x86); //--
LCD_WR_REG(0x36); // Memory Access Control
LCD_WR_DATA8_SSI(0x48);
LCD_WR_REG(0x3A);
LCD_WR_DATA8_SSI(0x55);
LCD_WR_REG(0xB1);
LCD_WR_DATA8_SSI(0x00);
LCD_WR_DATA8_SSI(0x18);
LCD_WR_REG(0xB6); // Display Function Control
LCD_WR_DATA8_SSI(0x08);
LCD_WR_DATA8_SSI(0x82);
LCD_WR_DATA8_SSI(0x27);
LCD_WR_REG(0xF2); // 3Gamma Function Disable
LCD_WR_DATA8_SSI(0x00);
LCD_WR_REG(0x26); //Gamma curve selected
LCD_WR_DATA8_SSI(0x01);
LCD_WR_REG(0xE0); //Set Gamma
LCD_WR_DATA8_SSI(0x0F);
LCD_WR_DATA8_SSI(0x31);
LCD_WR_DATA8_SSI(0x2B);
LCD_WR_DATA8_SSI(0x0C);
LCD_WR_DATA8_SSI(0x0E);
LCD_WR_DATA8_SSI(0x08);
LCD_WR_DATA8_SSI(0x4E);
LCD_WR_DATA8_SSI(0xF1);
LCD_WR_DATA8_SSI(0x37);
LCD_WR_DATA8_SSI(0x07);
LCD_WR_DATA8_SSI(0x10);
LCD_WR_DATA8_SSI(0x03);
LCD_WR_DATA8_SSI(0x0E);
LCD_WR_DATA8_SSI(0x09);
LCD_WR_DATA8_SSI(0x00);
LCD_WR_REG(0XE1); //Set Gamma
LCD_WR_DATA8_SSI(0x00);
LCD_WR_DATA8_SSI(0x0E);
LCD_WR_DATA8_SSI(0x14);
LCD_WR_DATA8_SSI(0x03);
LCD_WR_DATA8_SSI(0x11);
LCD_WR_DATA8_SSI(0x07);
LCD_WR_DATA8_SSI(0x31);
LCD_WR_DATA8_SSI(0xC1);
LCD_WR_DATA8_SSI(0x48);
LCD_WR_DATA8_SSI(0x08);
LCD_WR_DATA8_SSI(0x0F);
LCD_WR_DATA8_SSI(0x0C);
LCD_WR_DATA8_SSI(0x31);
LCD_WR_DATA8_SSI(0x36);
LCD_WR_DATA8_SSI(0x0F);
LCD_WR_REG(0x11); //Exit Sleep
// delayms(120);
SysCtlDelay(SysFreq/2);// 200 ms delay
LCD_WR_REG(0x29); //Display on
LCD_WR_REG(0x2c);
}
//void TFT_Set_Address(unsigned int PX1,unsigned int PY1,unsigned int PX2,unsigned int PY2)
//{
// Write_Command_Data(68,(PX2 << 8) + PX1 ); //Column address start2
// Write_Command_Data(69,PY1); //Column address start1
// Write_Command_Data(70,PY2); //Column address end2
// Write_Command_Data(78,PX1); //Column address end1
// Write_Command_Data(79,PY1); //Row address start2
// Write_Command(34);
//}
//
//void TFT_Fill(unsigned int color)
//{
// unsigned int i,j;
//// TFT_CS = 0;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_CS,0);
// TFT_Set_Address(0,0,239,319);
//
// Write_Data(color);
//
// for(i = 0; i <= 319; i++)
// {
// for(j = 0; j <= 239; j++)
// {
// //TFT_WR = 0;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_WR,0);
// //TFT_WR = 1;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_WR,LCD_WR);
// }
// }
// TFT_CS = 1;
// GPIOPinWrite(GPIO_PORTC_BASE, LCD_CS,LCD_CS);
//}
//
//// Clear screen function
////Color:To clear the screen filled with color
void LCD_Clear(u16 Color) // CONVERTED TO CCS
{
u8 VH,VL;
u16 i,j;
int x=1,y=1;
VH=Color>>8;
VL=Color;
// kkk = 100;
// kkkbk =0
Address_set(0,0,LCD_W,LCD_H);
for(i=0;i<LCD_W;i++)
{
for (j=0;j<LCD_H;j++) // LCD_H
{
LCD_WR_DATA8_SSI(VH);
LCD_WR_DATA8_SSI(VL);
}
}
// kkkbk = kkk+1;
// kkk += 1;
// if(kkk > 240)
// {
// kkk = 1;
// kkkbk = 0;
// }
}
////Dotted
////POINT_COLOR:The color of this point
void LCD_DrawPoint(u16 x,u16 y)
{
Address_set(x,y,x,y);//Setting the cursor position
LCD_WR_DATA(POINT_COLOR);
}
//// Draw a big point
////POINT_COLOR:The color of this point
//void LCD_DrawPoint_big(u16 x,u16 y) // CONVERTED TO CCS
//{
// LCD_Fill(x-1,y-1,x+1,y+1,POINT_COLOR);
//}
// Fill in the designated area specified color
// Size of the area:
// (xend-xsta)*(yend-ysta)
void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color) // CONVERTED TO CCS
{
u16 i,j;
Address_set(xsta,ysta,xend,yend); //Setting the cursor position
for(i=ysta;i<=yend;i++)
{
for(j=xsta;j<=xend;j++)LCD_WR_DATA(color);//Setting the cursor position
}
}
// Draw the line
//x1,y1:Starting point coordinates
//x2,y2:End coordinates
void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2) // CONVERTED TO CCS
{
u16 t;
int xerr=0,yerr=0,delta_x,delta_y,distance;
int incx,incy,uRow,uCol;
delta_x=x2-x1; //Calculate the coordinates of the incremental
delta_y=y2-y1;
uRow=x1;
uCol=y1;
if(delta_x>0)incx=1; //Set single-step directions
else if(delta_x==0)incx=0;//Vertical line
else {incx=-1;delta_x=-delta_x;}
if(delta_y>0)incy=1;
else if(delta_y==0)incy=0;//Level
else{incy=-1;delta_y=-delta_y;}
if( delta_x>delta_y)distance=delta_x; //Select the basic incremental axis
else distance=delta_y;
for(t=0;t<=distance+1;t++ )//Drawing a line output
{
LCD_DrawPoint(uRow,uCol);//Dotted
xerr+=delta_x ;
yerr+=delta_y ;
if(xerr>distance)
{
xerr-=distance;
uRow+=incx;
}
if(yerr>distance)
{
yerr-=distance;
uCol+=incy;
}
}
}
//Draw a rectangle
void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2) // CONVERTED TO CCS
{
LCD_DrawLine(x1,y1,x2,y1);
LCD_DrawLine(x1,y1,x1,y2);
LCD_DrawLine(x1,y2,x2,y2);
LCD_DrawLine(x2,y1,x2,y2);
}
//A circle the size of the appointed position draw
//(x,y):The center
//r :Radius
void Draw_Circle(u16 x0,u16 y0,u8 r) // CONVERTED TO CCS
{
int a,b;
int di;
a=0;b=r;
di=3-(r<<1); //Judgment flag next point position
while(a<=b)
{
LCD_DrawPoint(x0-b,y0-a); //3
LCD_DrawPoint(x0+b,y0-a); //0
LCD_DrawPoint(x0-a,y0+b); //1
LCD_DrawPoint(x0-b,y0-a); //7
LCD_DrawPoint(x0-a,y0-b); //2
LCD_DrawPoint(x0+b,y0+a); //4
LCD_DrawPoint(x0+a,y0-b); //5
LCD_DrawPoint(x0+a,y0+b); //6
LCD_DrawPoint(x0-b,y0+a);
a++;
//Using the Bresenham algorithm Circle
if(di<0)di +=4*a+6;
else
{
di+=10+4*(a-b);
b--;
}
LCD_DrawPoint(x0+a,y0+b);
}
}
////Displays a character at the specified position
//
//// num "" ---> "~"
//// mode: overlay mode (1) or non-overlapping mode (0)
//// Display a character at the specified location
//
void LCD_ShowChar(u16 x,u16 y,u8 num,u8 mode) // CONVERTED TO CCS
{
u8 temp;
u8 pos,t;
u16 x0=x;
u16 colortemp=POINT_COLOR;
if(x>LCD_W-16||y>LCD_H-16)
{
return;
}
//Settings window
num=num-' ';//Obtained after the offset value
Address_set(x,y,x+8-1,y+16-1); //Setting the cursor position
if(!mode) //Non-overlapping mode
{
for(pos=0;pos<16;pos++)
{
temp=asc2_1608[(u16)num*16+pos]; //Call 1608 fonts
for(t=0;t<8;t++)
{
if(temp&0x01)POINT_COLOR=colortemp;
else POINT_COLOR=BACK_COLOR;
LCD_WR_DATA(POINT_COLOR);
temp>>=1;
x++;
}
x=x0;
y++;
}
}else//Superimposition
{
for(pos=0;pos<16;pos++)
{
temp=asc2_1608[(u16)num*16+pos]; //Call 1608 fonts
for(t=0;t<8;t++)
{
if(temp&0x01)LCD_DrawPoint(x+t,y+pos);//Draw a point
temp>>=1;
}
}
}
POINT_COLOR=colortemp;
}
// m ^ n function
u32 mypow(u8 m,u8 n)
{
u32 result=1;
while(n--)result*=m;
return result;
}
// Show two figures
// x, y: starting point coordinates
// len: Digits
// color: color
// num: value (0 to 4294967295);
void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len) // CONVERTED TO CCS
{
u8 t,temp;
u8 enshow=0;
num=(u16)num;
for(t=0;t<len;t++)
{
temp=(num/mypow(10,len-t-1))%10;
if(enshow==0&&t<(len-1))
{
if(temp==0)
{
LCD_ShowChar(x+8*t,y,' ',0);
continue;
}else enshow=1;
}
LCD_ShowChar(x+8*t,y,temp+48,0);
}
}
// Show two figures
// x, y: starting point coordinates
// num: number (0 to 99);
void LCD_Show2Num(u16 x,u16 y,u16 num,u8 len) // CONVERTED TO CCS
{
u8 t,temp;
for(t=0;t<len;t++)
{
temp=(num/mypow(10,len-t-1))%10;
LCD_ShowChar(x+8*t,y,temp+'0',0);
}
}
// Display the string
// x, y: starting point coordinates
// * p: string starting address
// With 16 fonts
void LCD_ShowString(u16 x,u16 y,const u8 *p) // CONVERTED TO CCS
{
while(*p!='\0')
{
if(x>LCD_W-16){x=0;y+=16;}
if(y>LCD_H-16)
{
y=x=0;
LCD_Clear(RED);
}
LCD_ShowChar(x,y,*p,0);
x+=8;
p++;
}
}
//
//// Display a character (32 * 33 size) at the specified location
//// dcolor content color, gbcolor for Beijing color
//void show_char(unsigned int x,unsigned int y,unsigned char index) // CONVERTED TO CCS
//{
// unsigned char i,j;
// unsigned char *temp=symbol;
// Address_set(x,y,x+31,y+31); //Settings area
// temp+=index*128;
// for(j=0;j<128;j++)
// {
// for(i=0;i<8;i++)
// {
// if((*temp&(1<<i))!=0)
// {
// LCD_WR_DATA(POINT_COLOR);
// }
// else
// {
// LCD_WR_DATA(BACK_COLOR);
// }
// }
// temp++;
// }
//}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////ENABLING PORTS//////////////////////////////////////////////
void TivaInit(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // PE4 = D/C' , PE5 = RESET
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // LEDs for debugging only, not requierd in final
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);// SSI pins
SysCtlDelay(SysFreq/10);// 100mS delay
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LPLEDs);
/////////////////////OTHER CONTROL LINES////////////////////////////////////////////
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, CS);//
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, DC|RESET);
/////////////////SSI CONFIG HERE//////////////////////////////////////////////////////
SSIDisable(SSI0_BASE); // disables th SSI module as required for init
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA4_SSI0RX);
GPIOPinConfigure(GPIO_PA5_SSI0TX);
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4|GPIO_PIN_5);
SSIClockSourceSet(SSI0_BASE, SSI_CLOCK_SYSTEM); // sets the system clock as the source of clock
SSIConfigSetExpClk(SSI0_BASE, SysFreq, SSI_FRF_MOTO_MODE_2,SSI_MODE_MASTER, 20000000, 8);// defines base, System clk, Mode 0 = SPH = SPO = 0,Master, 400 KHz, no. of bits = 8 = 1 byte transfer
SSIEnable(SSI0_BASE); // enables SSI
////////////////////// SSI CONFIG ENDS/////////////////////////////////////////
