1913 views|2 replies

101

Posts

1

Resources
The OP
 

[Jihai APM32F407 Tiny Board] SPI lights up the ST7796S LCD screen [Copy link]

 

SPI Applications

NSS Description

NSS

Software NSS mode: The NSS pin can be used for other purposes.

Master Hardware NSS Mode: NSS output, single master mode. NSS Off Output: Allows operation in a multi-master environment.

Slave device hardware NSS mode: The NSS signal is set to low level as the chip select signal of the slave.

Structure SPI_Config_T


typedef struct
{
SPI_MODE_T          mode;           /!< SPI mode selection /
SPI_DATA_LENGTH_T   length;         /!< SPI data length selection /
SPI_CLKPHA_T        phase;          /!< SPI clock phase selection /
SPI_CLKPOL_T        polarity;       /!< SPI clock polarity selection /
SPI_NSS_T           nss;            /!< Set SPI software NSS /
SPI_FIRSTBIT_T      firstBit;       /!< Set first bit /
SPI_DIRECTION_T     direction;      /!< SPI data direction mode selection /
SPI_BAUDRATE_DIV_T  baudrateDiv;    /!< SPI BaudRate Prescaler selection /
uint16_t            crcPolynomial;  /!< Setup CRC polynomial value */
} SPI_Config_T;

Member Name

Functional Description

mode

SPI mode selection configuration master or slave

length

SPI data frame selects 8bit or 16bit

phase

SPI clock phase selection

polarity

SPI clock polarity selection

nss

Set SPI chip select

firstBit

Big-endian or little-endian configuration

direction

SPI data direction mode selection

  • SPI_DIRECTION_2LINES_FULLDUPLEX 2-line full-duplex
  • SPI_DIRECTION_2LINES_RXONLY 2 lines but only receive
  • SPI_DIRECTION_1LINE_RX 1 line only receives
  • SPI_DIRECTION_1LINE_TX 1 line only sends

baudrateDiv

SPI baud rate divider selection

crcPolynomial

Set the CRC polynomial value

Function Prototype

void SPI_I2S_Reset(SPI_T* spi)

Functional Description

Reset the specified SPIx peripheral

Input parameters {in}

Function Prototype

void SPI_Config(SPI_T* spi, SPI_Config_T* spiConfig)

Functional Description

Configure the SPI peripheral according to the parameters specified in spiConfig

Input parameters {in}

Function Prototype

void I2S_Config(SPI_T* spi, I2S_Config_T* i2sConfig)

Functional Description

Configure the I2S peripheral according to the parameters specified in I2S_Config_T

Input parameters {in}

Function Prototype

void SPI_ConfigStructInit(SPI_Config_T* spiConfig)

Functional Description

Fill each SPI_Config_T member with default values

Input parameters {in}

Function Prototype

void SPI_ConfigDataSize(SPI_T* spi, SPI_DATA_LENGTH_T length)

Functional Description

Configure the data size of the selected SPI.

Input parameters {in}

Function Prototype

void SPI_SetSoftwareNSS(SPI_T* spi)

Functional Description

Set the internal chip select signal

Input parameters {in}



#include "spi.h"

/*****************************************************************************
 * [url=home.php?mod=space&uid=32621]@name[/url] :u8 SPI_WriteByte(SPI_TypeDef* SPIx,u8 Byte)
 * [url=home.php?mod=space&uid=311857]@date[/url] :2018-08-09 
 * [url=home.php?mod=space&uid=665173]@FUNCTION[/url] :Write a byte of data using STM32's hardware SPI
 * @parameters :SPIx: SPI type,x for 1,2,3
                Byte:Data to be written
 * @retvalue   :Data received by the bus
******************************************************************************/
u8 SPI_WriteByte(SPI_T* SPIx,u8 Byte)
{
	 while (SPI_I2S_ReadStatusFlag(SPIx, SPI_FLAG_TXBE) == RESET);//等待为空

   SPI_I2S_TxData(SPIx, Byte);
   while (SPI_I2S_ReadStatusFlag(SPIx, SPI_FLAG_RXBNE) == RESET);
	
	 return SPIx ->DATA;
} 

///*****************************************************************************
// * @name       :void SPI_SetSpeed(SPI_TypeDef* SPIx,u8 SpeedSet)
// * @date       :2018-08-09 
// * @function   :Set hardware SPI Speed
// * @parameters :SPIx: SPI type,x for 1,2,3
//                SpeedSet:0-high speed
//												 1-low speed
// * @retvalue   :None
//******************************************************************************/
//void SPI_SetSpeed(SPI_TypeDef* SPIx,u8 SpeedSet)
//{
//	SPIx->CR1&=0XFFC7;
//	if(SpeedSet==1)//高速
//	{
//		SPIx->CR1|=SPI_BaudRatePrescaler_2;//Fsck=Fpclk/2	
//	}
//	else//低速
//	{
//		SPIx->CR1|=SPI_BaudRatePrescaler_32; //Fsck=Fpclk/32
//	}
//	SPIx->CR1|=1<<6; //SPI设备使能
//} 

/*****************************************************************************
 * @name       :void SPI2_Init(void)	
 * @date       :2018-08-09 
 * @function   :Initialize the STM32 hardware SPI2
 * @parameters :None
 * @retvalue   :None
******************************************************************************/
void SPI2_Init(void)	
{
	  GPIO_Config_T GPIO_InitStructure;
    SPI_Config_T  SPI2_InitStructure;

    /** Enable related Clock */
	  RCM_EnableAHB1PeriphClock (RCM_AHB1_PERIPH_GPIOC);
    RCM_EnableAHB1PeriphClock (RCM_AHB1_PERIPH_GPIOB);
    RCM_EnableAPB1PeriphClock(RCM_APB1_PERIPH_SPI2);
    RCM_EnableAPB2PeriphClock(RCM_APB2_PERIPH_SYSCFG);
	
    /** Config SPI2 PinAF */
    GPIO_ConfigPinAF(GPIOB, GPIO_PIN_SOURCE_12, GPIO_AF_SPI2);
    GPIO_ConfigPinAF(GPIOB, GPIO_PIN_SOURCE_13, GPIO_AF_SPI2);
//    GPIO_ConfigPinAF(GPIOB, GPIO_PIN_SOURCE_14, GPIO_AF_SPI2);
    GPIO_ConfigPinAF(GPIOC, GPIO_PIN_SOURCE_3,  GPIO_AF_SPI2);
    GPIO_ConfigPinAF(GPIOC, GPIO_PIN_SOURCE_2,  GPIO_AF_SPI2);
    /** Config SPI2, PIN NSS=PB12, SCK=PB13, MISO=PB14, MOSI=PB15 */
//    GPIO_ConfigStructInit(&GPIO_InitStructure);
    GPIO_InitStructure.pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14;
    GPIO_InitStructure.speed = GPIO_SPEED_100MHz;
    GPIO_InitStructure.mode = GPIO_MODE_AF;
    GPIO_InitStructure.otype = GPIO_OTYPE_PP;
    GPIO_InitStructure.pupd = GPIO_PUPD_NOPULL;
    GPIO_Config(GPIOB, &GPIO_InitStructure);
		
		GPIO_InitStructure.pin = GPIO_PIN_3|GPIO_PIN_2;
		GPIO_Config(GPIOC, &GPIO_InitStructure);

    /** Config SPI2 */
    SPI_ConfigStructInit(&SPI2_InitStructure);
    SPI2_InitStructure.direction = SPI_DIRECTION_2LINES_FULLDUPLEX;
    SPI2_InitStructure.mode = SPI_MODE_MASTER;
    SPI2_InitStructure.length = SPI_DATA_LENGTH_8B;
    SPI2_InitStructure.polarity = SPI_CLKPOL_LOW;
    SPI2_InitStructure.phase = SPI_CLKPHA_1EDGE;
    SPI2_InitStructure.nss = SPI_NSS_SOFT;
    SPI2_InitStructure.baudrateDiv = SPI_BAUDRATE_DIV_64;
    SPI2_InitStructure.firstBit = SPI_FIRSTBIT_MSB;
    SPI2_InitStructure.crcPolynomial = 7;
    SPI_Config(SPI2, &SPI2_InitStructure);
    SPI_DisableCRC(SPI2);

    /** Enable SPI  */
    SPI_Enable(SPI2);
}


#ifndef __LCD_H
#define __LCD_H		

#include "apm32f4xx.h"
#include "stdlib.h"

//LCD重要参数集
typedef struct  
{										    
	u16 width;			//LCD 宽度
	u16 height;			//LCD 高度
	u16 id;				  //LCD ID
	u8  dir;			  //横屏还是竖屏控制:0,竖屏;1,横屏。	
	u16	 wramcmd;		//开始写gram指令
	u16  setxcmd;		//设置x坐标指令
	u16  setycmd;		//设置y坐标指令	 
}_lcd_dev; 	

//LCD参数
extern _lcd_dev lcddev;	//管理LCD重要参数
/////////////////////////////////////用户配置区///////////////////////////////////	 
#define USE_HORIZONTAL  	 0 //定义液晶屏顺时针旋转方向 	0-0度旋转,1-90度旋转,2-180度旋转,3-270度旋转

//////////////////////////////////////////////////////////////////////////////////	  
//定义LCD的尺寸
#define LCD_W 320
#define LCD_H 480

//TFTLCD部分外要调用的函数		   
extern u16  POINT_COLOR;//默认红色    
extern u16  BACK_COLOR; //背景颜色.默认为白色

//////////////////////////////////////////////////////////////////////
////-----------------LCD端口定义---------------- 
//#define GPIO_TYPE  GPIOB  //GPIO组类型
//#define LED      9        //背光控制引脚        PB9
//#define LCD_CS   11       //片选引脚            PB11
//#define LCD_RS   10       //寄存器/数据选择引脚 PB10 
//#define LCD_RST  12       //复位引脚            PB12


//QDtech全系列模块采用了三极管控制背光亮灭,用户也可以接PWM调节背光亮度
#define	LCD_LED(x) GPIO_WriteBitValue(GPIOB, GPIO_PIN_10,x) //LCD背光    		 PB9
//如果使用官方库函数定义下列底层,速度将会下降到14帧每秒,建议采用我司推荐方法
//以下IO定义直接操作寄存器,快速IO操作,刷屏速率可以达到28帧每秒! 

//GPIO置位(拉高)
#define	LCD_CS_SET  GPIO_WriteBitValue(GPIOB, GPIO_PIN_9,1)    //片选端口  	PB11
#define	LCD_RS_SET	GPIO_WriteBitValue(GPIOB, GPIO_PIN_8,1)    //数据/命令  PB10	  
#define	LCD_RST_SET	GPIO_WriteBitValue(GPIOB, GPIO_PIN_7,1)   //复位			  PB12

//GPIO复位(拉低)							    
#define	LCD_CS_CLR  GPIO_WriteBitValue(GPIOB, GPIO_PIN_9,0)     //片选端口  	PB11
#define	LCD_RS_CLR	GPIO_WriteBitValue(GPIOB, GPIO_PIN_8,0)     //数据/命令  PB10	 
#define	LCD_RST_CLR	GPIO_WriteBitValue(GPIOB, GPIO_PIN_7,0)    //复位			  PB12

//画笔颜色
#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 //棕色
#define BRRED 			0XFC07 //棕红色
#define GRAY  			0X8430 //灰色
//GUI颜色

#define DARKBLUE      	 0X01CF	//深蓝色
#define LIGHTBLUE      	 0X7D7C	//浅蓝色  
#define GRAYBLUE       	 0X5458 //灰蓝色
//以上三色为PANEL的颜色 
 
#define LIGHTGREEN     	0X841F //浅绿色
#define LIGHTGRAY     0XEF5B //浅灰色(PANNEL)
#define LGRAY 			 		0XC618 //浅灰色(PANNEL),窗体背景色

#define LGRAYBLUE      	0XA651 //浅灰蓝色(中间层颜色)
#define LBBLUE          0X2B12 //浅棕蓝色(选择条目的反色)
	    															  
void LCD_Init(void);
void LCD_DisplayOn(void);
void LCD_DisplayOff(void);
void LCD_Clear(u16 Color);	 
void LCD_SetCursor(u16 Xpos, u16 Ypos);
void LCD_DrawPoint(u16 x,u16 y);//画点
u16  LCD_ReadPoint(u16 x,u16 y); //读点
void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2);
void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2);		   
void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd);

u16 LCD_RD_DATA(void);//读取LCD数据									    
void LCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue);
void LCD_WR_DATA(u8 data);
u16 LCD_ReadReg(u8 LCD_Reg);
void LCD_WriteRAM_Prepare(void);
void LCD_WriteRAM(u16 RGB_Code);
u16 LCD_ReadRAM(void);		   
u16 LCD_BGR2RGB(u16 c);
void LCD_SetParam(void);
void Lcd_WriteData_16Bit(u16 Data);
void LCD_direction(u8 direction );

//如果仍然觉得速度不够快,可以使用下面的宏定义,提高速度.
//注意要去掉lcd.c中void LCD_WR_DATA(u16 data)函数定义哦
/*

				  		 
#endif  
	 


#include "lcd.h"
#include "stdlib.h"
#include "SysTick_Delay.h" 
#include "SPI.h"

	   
//管理LCD重要参数
//默认为竖屏
_lcd_dev lcddev;

//画笔颜色,背景颜色
u16 POINT_COLOR = 0x0000,BACK_COLOR = 0xFFFF;  
u16 DeviceCode;	 

/*****************************************************************************
 * @name       :void LCD_WR_REG(u8 data)
 * @date       :2018-08-09 
 * @function   :Write an 8-bit command to the LCD screen
 * @parameters :data:Command value to be written
 * @retvalue   :None
******************************************************************************/
void LCD_WR_REG(u8 data)
{ 
   LCD_CS_CLR;     
	 LCD_RS_CLR;	  
   SPI_WriteByte(SPI2,data);
   LCD_CS_SET;	
}

/*****************************************************************************
 * @name       :void LCD_WR_DATA(u8 data)
 * @date       :2018-08-09 
 * @function   :Write an 8-bit data to the LCD screen
 * @parameters :data:data value to be written
 * @retvalue   :None
******************************************************************************/
void LCD_WR_DATA(u8 data)
{
   LCD_CS_CLR;
	 LCD_RS_SET;
   SPI_WriteByte(SPI2,data);
   LCD_CS_SET;
}

/*****************************************************************************
 * @name       :void LCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue)
 * @date       :2018-08-09 
 * @function   :Write data into registers
 * @parameters :LCD_Reg:Register address
                LCD_RegValue:Data to be written
 * @retvalue   :None
******************************************************************************/
void LCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue)
{	
	LCD_WR_REG(LCD_Reg);  
	LCD_WR_DATA(LCD_RegValue);	    		 
}	   

/*****************************************************************************
 * @name       :void LCD_WriteRAM_Prepare(void)
 * @date       :2018-08-09 
 * @function   :Write GRAM
 * @parameters :None
 * @retvalue   :None
******************************************************************************/	 
void LCD_WriteRAM_Prepare(void)
{
	LCD_WR_REG(lcddev.wramcmd);
}	 

/*****************************************************************************
 * @name       :void Lcd_WriteData_16Bit(u16 Data)
 * @date       :2018-08-09 
 * @function   :Write an 16-bit command to the LCD screen
 * @parameters :Data:Data to be written
 * @retvalue   :None
******************************************************************************/	 
void Lcd_WriteData_16Bit(u16 Data)
{	
	 LCD_CS_CLR;
	 LCD_RS_SET;
   SPI_WriteByte(SPI2,Data>>8);
   SPI_WriteByte(SPI2,Data);
	 LCD_CS_SET;
}

/*****************************************************************************
 * @name       :void LCD_DrawPoint(u16 x,u16 y)
 * @date       :2018-08-09 
 * @function   :Write a pixel data at a specified location
 * @parameters :x:the x coordinate of the pixel
                y:the y coordinate of the pixel
 * @retvalue   :None
******************************************************************************/	
void LCD_DrawPoint(u16 x,u16 y)
{
	LCD_SetCursor(x,y);//设置光标位置 
	Lcd_WriteData_16Bit(POINT_COLOR); 
}

/*****************************************************************************
 * @name       :void LCD_Clear(u16 Color)
 * @date       :2018-08-09 
 * @function   :Full screen filled LCD screen
 * @parameters :color:Filled color
 * @retvalue   :None
******************************************************************************/	
void LCD_Clear(u16 Color)
{
  unsigned int i,m;  
	LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);   
	LCD_CS_CLR;
	LCD_RS_SET;
	for(i=0;i<lcddev.height;i++)
	{
    for(m=0;m<lcddev.width;m++)
    {	
			Lcd_WriteData_16Bit(Color);
		}
	}
	 LCD_CS_SET;
} 

/*****************************************************************************
 * @name       :void LCD_Clear(u16 Color)
 * @date       :2018-08-09 
 * @function   :Initialization LCD screen GPIO
 * @parameters :None
 * @retvalue   :None
******************************************************************************/	
void LCD_GPIOInit(void)
{
	  GPIO_Config_T  configStruct;

    /** 开启GPIO_LED时钟 */
    RCM_EnableAHB1PeriphClock(RCM_AHB1_PERIPH_GPIOB);

    /** 配置GPIO_LED引脚 */
    GPIO_ConfigStructInit(&configStruct);
    configStruct.pin = GPIO_PIN_7;    //不支持或
    configStruct.mode = GPIO_MODE_OUT;
    configStruct.speed = GPIO_SPEED_50MHz;
    GPIO_Config(GPIOB, &configStruct);
	
    configStruct.pin = GPIO_PIN_10;    //不支持或
    GPIO_Config(GPIOB, &configStruct);
	  
	  configStruct.pin = GPIO_PIN_9;    //不支持或
    GPIO_Config(GPIOB, &configStruct);
	  
	  configStruct.pin = GPIO_PIN_8;    //不支持或
    GPIO_Config(GPIOB, &configStruct);
	
	  //设置GPIO为低电平,不点亮LED
    GPIO_SetBit(GPIOB, GPIO_PIN_10);
    GPIO_SetBit(GPIOB, GPIO_PIN_9);
		GPIO_SetBit(GPIOB, GPIO_PIN_8);
		GPIO_SetBit(GPIOB, GPIO_PIN_7);
}

/*****************************************************************************
 * @name       :void LCD_RESET(void)
 * @date       :2018-08-09 
 * @function   :Reset LCD screen
 * @parameters :None
 * @retvalue   :None
******************************************************************************/	
void LCD_RESET(void)
{
	LCD_RST_CLR;
	SysTick_Delay_ms(100);	
	LCD_RST_SET;
	SysTick_Delay_ms(50);
}

/*****************************************************************************
 * @name       :void LCD_RESET(void)
 * @date       :2018-08-09 
 * @function   :Initialization LCD screen
 * @parameters :None
 * @retvalue   :None
******************************************************************************/	 	 
void LCD_Init(void)
{  
	SPI2_Init(); //硬件SPI2初始化
	LCD_GPIOInit();//LCD GPIO初始化										 
 	LCD_RESET(); //LCD 复位
//************* ST7796S初始化**********//	
	LCD_WR_REG(0xF0);
	LCD_WR_DATA(0xC3);
	LCD_WR_REG(0xF0);
	LCD_WR_DATA(0x96);
	LCD_WR_REG(0x36);
	LCD_WR_DATA(0x68);	
	LCD_WR_REG(0x3A);
	LCD_WR_DATA(0x05);	
	LCD_WR_REG(0xB0);
	LCD_WR_DATA(0x80);	
	LCD_WR_REG(0xB6);
	LCD_WR_DATA(0x00);
	LCD_WR_DATA(0x02);	
	LCD_WR_REG(0xB5);
	LCD_WR_DATA(0x02);
	LCD_WR_DATA(0x03);
	LCD_WR_DATA(0x00);
	LCD_WR_DATA(0x04);
	LCD_WR_REG(0xB1);
	LCD_WR_DATA(0x80);	
	LCD_WR_DATA(0x10);	
	LCD_WR_REG(0xB4);
	LCD_WR_DATA(0x00);
	LCD_WR_REG(0xB7);
	LCD_WR_DATA(0xC6);
	LCD_WR_REG(0xC5);
	LCD_WR_DATA(0x24);
	LCD_WR_REG(0xE4);
	LCD_WR_DATA(0x31);
	LCD_WR_REG(0xE8);
	LCD_WR_DATA(0x40);
	LCD_WR_DATA(0x8A);
	LCD_WR_DATA(0x00);
	LCD_WR_DATA(0x00);
	LCD_WR_DATA(0x29);
	LCD_WR_DATA(0x19);
	LCD_WR_DATA(0xA5);
	LCD_WR_DATA(0x33);
	LCD_WR_REG(0xC2);
	LCD_WR_REG(0xA7);
	
	LCD_WR_REG(0xE0);
	LCD_WR_DATA(0xF0);
	LCD_WR_DATA(0x09);
	LCD_WR_DATA(0x13);
	LCD_WR_DATA(0x12);
	LCD_WR_DATA(0x12);
	LCD_WR_DATA(0x2B);
	LCD_WR_DATA(0x3C);
	LCD_WR_DATA(0x44);
	LCD_WR_DATA(0x4B);
	LCD_WR_DATA(0x1B);
	LCD_WR_DATA(0x18);
	LCD_WR_DATA(0x17);
	LCD_WR_DATA(0x1D);
	LCD_WR_DATA(0x21);

	LCD_WR_REG(0XE1);
	LCD_WR_DATA(0xF0);
	LCD_WR_DATA(0x09);
	LCD_WR_DATA(0x13);
	LCD_WR_DATA(0x0C);
	LCD_WR_DATA(0x0D);
	LCD_WR_DATA(0x27);
	LCD_WR_DATA(0x3B);
	LCD_WR_DATA(0x44);
	LCD_WR_DATA(0x4D);
	LCD_WR_DATA(0x0B);
	LCD_WR_DATA(0x17);
	LCD_WR_DATA(0x17);
	LCD_WR_DATA(0x1D);
	LCD_WR_DATA(0x21);

  LCD_WR_REG(0X36);
	LCD_WR_DATA(0xEC);
	LCD_WR_REG(0xF0);
	LCD_WR_DATA(0xC3);
	LCD_WR_REG(0xF0);
	LCD_WR_DATA(0x69);
	LCD_WR_REG(0X13);
	LCD_WR_REG(0X11);
	LCD_WR_REG(0X29);
	
  LCD_direction(USE_HORIZONTAL);//设置LCD显示方向
	LCD_LED(1);//点亮背光	 
	LCD_Clear(WHITE);//清全屏白色
}
 
/*****************************************************************************
 * @name       :void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd)
 * @date       :2018-08-09 
 * @function   :Setting LCD display window
 * @parameters :xStar:the bebinning x coordinate of the LCD display window
								yStar:the bebinning y coordinate of the LCD display window
								xEnd:the endning x coordinate of the LCD display window
								yEnd:the endning y coordinate of the LCD display window
 * @retvalue   :None
******************************************************************************/ 
void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd)
{	
	LCD_WR_REG(lcddev.setxcmd);	
	LCD_WR_DATA(xStar>>8);
	LCD_WR_DATA(0x00FF&xStar);		
	LCD_WR_DATA(xEnd>>8);
	LCD_WR_DATA(0x00FF&xEnd);

	LCD_WR_REG(lcddev.setycmd);	
	LCD_WR_DATA(yStar>>8);
	LCD_WR_DATA(0x00FF&yStar);		
	LCD_WR_DATA(yEnd>>8);
	LCD_WR_DATA(0x00FF&yEnd);

	LCD_WriteRAM_Prepare();	//开始写入GRAM			
}   

/*****************************************************************************
 * @name       :void LCD_SetCursor(u16 Xpos, u16 Ypos)
 * @date       :2018-08-09 
 * @function   :Set coordinate value
 * @parameters :Xpos:the  x coordinate of the pixel
								Ypos:the  y coordinate of the pixel
 * @retvalue   :None
******************************************************************************/ 
void LCD_SetCursor(u16 Xpos, u16 Ypos)
{	  	    			
	LCD_SetWindows(Xpos,Ypos,Xpos,Ypos);	
} 

/*****************************************************************************
 * @name       :void LCD_direction(u8 direction)
 * @date       :2018-08-09 
 * @function   :Setting the display direction of LCD screen
 * @parameters :direction:0-0 degree
                          1-90 degree
													2-180 degree
													3-270 degree
 * @retvalue   :None
******************************************************************************/ 
void LCD_direction(u8 direction)
{ 
	lcddev.setxcmd=0x2A;
	lcddev.setycmd=0x2B;
	lcddev.wramcmd=0x2C;
	switch(direction){		  
		case 0:						 	 		
			lcddev.width=LCD_W;
			lcddev.height=LCD_H;		
			LCD_WriteReg(0x36,(1<<3)|(1<<6));
		break;
		case 1:
			lcddev.width=LCD_H;
			lcddev.height=LCD_W;
			LCD_WriteReg(0x36,(1<<3)|(1<<5));
		break;
		case 2:						 	 		
			lcddev.width=LCD_W;
			lcddev.height=LCD_H;	
			LCD_WriteReg(0x36,(1<<3)|(1<<7));
		break;
		case 3:
			lcddev.width=LCD_H;
			lcddev.height=LCD_W;
			LCD_WriteReg(0x36,(1<<3)|(1<<7)|(1<<6)|(1<<5));
		break;	
		default:break;
	}		
}	 

SPI_LCD.zip

6.4 MB, downloads: 29

This post is from Domestic Chip Exchange

Latest reply

u16 LCD_ReadPoint(u16 x,u16 y); //Read point I haven't seen this. Can you add more information about this function? Thank you  Details Published on 2024-3-26 20:09
 
 

6818

Posts

11

Resources
2
 
Sir, this post is really well written, and the project is paid for. Thank you very much for such a good post.
This post is from Domestic Chip Exchange
 
 
 

9

Posts

0

Resources
3
 

u16 LCD_ReadPoint(u16 x,u16 y); //Read point I haven't seen this. Can you add more information about this function? Thank you


This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list