⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ra8835.c

📁 GLCD WG320240C0-FMIVZ#000 driven by STR912FAW44.
💻 C
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------
//    File name   : lcd.c
//    Description : RA8835AP3N driver
//    History :
//    1. Date        : Feb 23, 2009
//       Author      : Chandrakant Bhor
//       Description : Create
//Connection to GLCD are as follows:
//
//------------------------------------------------------------------------------
#include "ra8835.h"
//------------------------------------------------------------------------------
//Variables
unsigned short CurrScreen = 0, PrevScreen = 0;
unsigned char CurrDet = 0,CurrInj = 0;
unsigned char P9Val = 0;
unsigned Refresh = 1;
float Temp;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//Strings
//------------------------------------------------------------------------------
// Function Name: LCDIOInit
// Parameters: none
// Return: none
// Description: Init IO ports directions and level
//------------------------------------------------------------------------------
void LCDIOInit (void)
{
  GPIO_InitTypeDef  GPIO_InitStructure;

  // Enable GPIO clocks
  SCU_APBPeriphClockConfig(__GPIO8 | __GPIO9, ENABLE);
  // Release GPIO reset
  SCU_APBPeriphReset(__GPIO8 | __GPIO9, DISABLE);

  // IO configure
  SCU->GPIOEMI &= 0;  
  SCU->GPIOTYPE[9] &=  ~(LCD_WR | LCD_A0 | LCD_CS);
  GPIO9->DDR |= LCD_WR | LCD_A0 | LCD_CS;

  GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
  GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;
  GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;
  GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
  GPIO_InitStructure.GPIO_Pin = LCD_DATA;
  GPIO_Init(GPIO8, &GPIO_InitStructure);
 
  P9Val |= LCD_WR | LCD_A0 | LCD_CS;
  GPIO_Write(GPIO9,P9Val);  
}
//------------------------------------------------------------------------------
// Function Name: LCDSetCS
// Parameters: unsigned char Data
// Return: none
// Description: Set CS signal
//------------------------------------------------------------------------------
void LCDSetCS (unsigned char Data)
{
  GPIO_WriteBit(GPIO9,LCD_CS,Data?Bit_SET:Bit_RESET);
}
//------------------------------------------------------------------------------
// Function Name: LCDSetA0
// Parameters: unsigned char Data
// Return: none
// Description: Set A0 signal
//------------------------------------------------------------------------------
void LCDSetA0 (unsigned char Data)
{
  GPIO_WriteBit(GPIO9,LCD_A0,Data?Bit_SET:Bit_RESET);
}
//------------------------------------------------------------------------------
// Function Name: LCDSetWR
// Parameters: unsigned char Data
// Return: none
// Description: Set WR signal
//------------------------------------------------------------------------------
void LCDSetWR (unsigned char Data)
{
  GPIO_WriteBit(GPIO9,LCD_WR,Data?Bit_SET:Bit_RESET);
}
//------------------------------------------------------------------------------
// Function Name: LCD_Cmd_Write (unsigned char Cmd)
// Parameters: unsigned char Data
// Return: none
// Description: Write cmd to LCD
//------------------------------------------------------------------------------
void LCDCmdWrite (unsigned char Cmd)
{
  GPIO_Write(GPIO8,Cmd);  //Data on Datalines.
  P9Val |= LCD_A0;
  GPIO_Write(GPIO9,P9Val);  // A0  Output - High  
  P9Val &= ~LCD_CS;
  GPIO_Write(GPIO9,P9Val);  // CS Output - Low    
  P9Val &= ~LCD_WR;
  GPIO_Write(GPIO9,P9Val);  // WR Output - Low
  P9Val |= LCD_WR;
  GPIO_Write(GPIO9,P9Val);  // WR Output - High  
  P9Val |= LCD_CS;
  GPIO_Write(GPIO9,P9Val);  // CS Output - High   
}
//------------------------------------------------------------------------------
// Function Name: LCDDataWrite (unsigned char Data);
// Parameters: unsigned char Data
// Return: none
// Description: Write cmd to LCD
//------------------------------------------------------------------------------
void LCDDataWrite (unsigned char Data)
{
  P9Val &= ~LCD_A0;
  GPIO_Write(GPIO9,P9Val);  // A0  Output - Low
  GPIO_Write(GPIO8,Data);   //Data on Datalines.
  P9Val &= ~LCD_CS;
  GPIO_Write(GPIO9,P9Val);  // CS  Output - Low
  P9Val &= ~LCD_WR;
  GPIO_Write(GPIO9,P9Val);  // WR Output - Low
  P9Val |= LCD_WR;
  GPIO_Write(GPIO9,P9Val);  // WR Output - High  
  P9Val |= LCD_CS;
  GPIO_Write(GPIO9,P9Val);  // CS Output - High
  P9Val |= LCD_A0;
  GPIO_Write(GPIO9,P9Val);  // A0  Output - High 
}
//------------------------------------------------------------------------------
// Function Name: LCDStsRead
// Parameters: none
// Return: unsigned char Data
// Description: Read LCD status
//------------------------------------------------------------------------------
unsigned char LCDStsRead (void)
{
  unsigned char status;
  GPIO_InitTypeDef  GPIO_InitStructure;
  
  // Set Direction
  GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
  GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;
  GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
  GPIO_InitStructure.GPIO_Pin = LCD_DATA;
  GPIO_Init(GPIO8, &GPIO_InitStructure);

  P9Val |= LCD_A0;
  GPIO_Write(GPIO9,P9Val);  // A0  Output - High  
  P9Val &= ~LCD_CS;
  GPIO_Write(GPIO9,P9Val);  // CS  Output - Low
  P9Val |= LCD_WR;
  GPIO_Write(GPIO9,P9Val);  // WR Output - High  

  P9Val &= ~LCD_WR;
  GPIO_Write(GPIO9,P9Val);  // WR Output - Low  
  P9Val |= LCD_CS;
  GPIO_Write(GPIO9,P9Val);  // CS  Output - High
  P9Val &= ~LCD_A0;
  GPIO_Write(GPIO9,P9Val);  // A0  Output - Low
  // Set Direction  
  GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
  GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;
  GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
  GPIO_InitStructure.GPIO_Pin = LCD_DATA;
  GPIO_Init(GPIO8, &GPIO_InitStructure);
  
  return(status);  
}
//------------------------------------------------------------------------------
// Function Name: LCDDataRead
// Parameters: none
// Return: unsigned char
// Description: Write cmd to LCD
//------------------------------------------------------------------------------
unsigned char LCDDataRead (void)
{
  unsigned char data;
  GPIO_InitTypeDef  GPIO_InitStructure;
  
  LCDCmdWrite(0x47);  //Read mem cmd.

  // Set Direction
  GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
  GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;
  GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
  GPIO_InitStructure.GPIO_Pin = LCD_DATA;
  GPIO_Init(GPIO8, &GPIO_InitStructure);

  P9Val &= ~LCD_A0;
  GPIO_Write(GPIO9,P9Val);  // A0  Output - Low
  P9Val &= ~LCD_CS;
  GPIO_Write(GPIO9,P9Val);  // CS  Output - Low  
  P9Val |= LCD_WR;
  GPIO_Write(GPIO9,P9Val);  // WR Output - High    

  data = GPIO_Read(GPIO8);

  P9Val &= ~LCD_WR;
  GPIO_Write(GPIO9,P9Val);  // WR Output - Low  
  P9Val |= LCD_CS;
  GPIO_Write(GPIO9,P9Val);  // CS  Output - High
  P9Val |= LCD_A0;
  GPIO_Write(GPIO9,P9Val);  // A0  Output - High
  
  // Set Direction  
  GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
  GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;
  GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;
  GPIO_InitStructure.GPIO_Pin = LCD_DATA;
  GPIO_Init(GPIO8, &GPIO_InitStructure);
  
  return(data);  
}
//------------------------------------------------------------------------------
// Function Name: ResetDisplay
// Parameters: none
// Return: none
// Description: function to reset the graphics display
//------------------------------------------------------------------------------
void ResetDisplay(void)
{
//  LCDSetRES(1);
//  Dly100us((void *)20);   //2 msec
  
  LCDSetA0(0);
  LCDSetWR(1);
  LCDSetCS(1);
//  LCDSetRES(0);
//  Dly100us((void *)5000);  //500 msec
  
//  LCDSetRES(1);
//  Dly100us((void *)5000);  //500 msec
}
//------------------------------------------------------------------------------
// Function Name: ClearGraphics
// Parameters: none
// Return: none
// Description: function to clear the graphic screen
//------------------------------------------------------------------------------
void ClearGraphics(void)
{
  unsigned short i;
  LCDMemWrite(0x00,0x10);
  for(i=0;i<9600;i++)
    LCDDataWrite(0x00);   
}
//------------------------------------------------------------------------------
// Function Name: ClearText
// Parameters: none
// Return: none
// Description: function to clear the Text screen
//------------------------------------------------------------------------------
void ClearText(void)
{
  unsigned short i;

  LCDMemWrite(0x00,0x00);
  for(i=0;i<1200;i++)
    LCDDataWrite(0x00);
}
//------------------------------------------------------------------------------
// Function Name: CurserOnOff
// Parameters: unsigned char Data
// Return: none
// Description: Cursor On/Off
//------------------------------------------------------------------------------
void CurserOnOff(unsigned char Data)
{
  LCDCmdWrite(0x59);           //Display cursor on
  LCDDataWrite(Data?0x16:0x14);
//  Data?currson = 1:currson = 0;
}
//------------------------------------------------------------------------------
// Function Name: Gotoxy

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -