📄 lcd_x_8bus.c
字号:
/*********************************Copyright(c)**********************************
**********************************千能电力**************************************
**--------------文件信息---------------------------------------------------
**文 件 名: LCD_X_8bus.c
**创 建 人: 杨林军
**创 建 日 期: 2008-3
**最 新 版 本: $Id$
**描 述:
**--------------历史版本信息-----------------------------------------------
** 修改人: 杨林军
** 日 期:
** 版 本:
** 描 述:
**-------------------------------------------------------------------------
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "bsp_globe.h"
#include "gpio.h"
#include "GUI_x.h"
#include "LCDConf.h"
/* Private typedef -----------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
#define GPIO_LCD_CS 11 //p1.11 液晶CS使用的P口
#define GPIO_LCD_A0 0 //P1.0 液晶A0使用的P口
#define LCD_CLR_RESET() ClrBitBusEnRl(BitResetLcd)
#define LCD_SET_RESET() SetBitBusEnRl(BitResetLcd)
/*******************************************************************************
如果液晶CS用CPU的物理CS脚控制,则把下面的宏改成
#define LCD_SET_CS() //GPIO_SET_BIT(GPIO1, GPIO_LCD_CS)
#define LCD_CLR_CS() //GPIO_CLR_BIT(GPIO1, GPIO_LCD_CS)
*******************************************************************************/
#define LCD_SET_CS() //GPIO_SET_BIT(GPIO1, GPIO_LCD_CS)
#define LCD_CLR_CS() //GPIO_CLR_BIT(GPIO1, GPIO_LCD_CS)
/*******************************************************************************
如果液晶A0用CPU的物理地址线控制,则把下面的宏改成
#define LCD_SET_A0() //GPIO_SET_BIT(GPIO1, GPIO_LCD_A0)
#define LCD_CLR_A0() //GPIO_CLR_BIT(GPIO1, GPIO_LCD_A0)
*******************************************************************************/
#define LCD_SET_A0() //GPIO_SET_BIT(GPIO1, GPIO_LCD_A0)
#define LCD_CLR_A0() //GPIO_CLR_BIT(GPIO1, GPIO_LCD_A0)
//#define ASSEMBAL //汇编或C语言的选择开关
/* Private variables ---------------------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Interface functions -------------------------------------------------------*/
/*********************************************************************
*
* Defaults
*
**********************************************************************
*/
#ifndef LCD_CLR_RW
#define LCD_CLR_RW()
#endif
#ifndef LCD_SET_RW
#define LCD_SET_RW()
#endif
#ifndef LCD_SET_CS0
#define LCD_SET_CS0()
#endif
#ifndef LCD_SET_CS1
#define LCD_SET_CS1()
#endif
#ifndef LCD_SET_CS2
#define LCD_SET_CS2()
#endif
#ifndef LCD_SET_DIR_IN
#define LCD_SET_DIR_IN()
#endif
#ifndef LCD_SET_DIR_OUT
#define LCD_SET_DIR_OUT()
#endif
/*********************************************************************
*
* Initialisation
*
**********************************************************************
This routine should be called from your application program
to set port pins to their initial values
GPIO_LCD_CS配置成输入是因为现在这个管脚与CS连着,改版后需删掉这句
*/
void LCD_X_Init(void) {
GPIO_Config(GPIO1, 1<<GPIO_LCD_A0, GPIO_OUT_PP); //配置A0
GPIO_Config(GPIO1, 1<<GPIO_LCD_CS, GPIO_IN_TRI_CMOS);
LCD_CLR_RESET();
GUI_X_Delay(1);
LCD_SET_RESET();
GUI_X_Delay(1);
//LCD_CLR_CS();
}
/*********************************************************************
*
* Access routines, controller 0
*
**********************************************************************
Usually, there is no need to modify these routines.
It should be sufficient ot modify the low-level macros
above.
*/
/* Read from controller 0, with A0 = 0, CS1 = 0*/
char LCD_X_Read00(void) {
char c;
LCD_CLR_A0();
LCD_CLR_CS();
c = LCDPortCmd;
LCD_SET_CS();
LCD_SET_A0();
return c;
}
/* Read from controller 0, with A0 = 1, CS1 = 0 */
char LCD_X_Read01(void) {
#ifdef ASSEMBAL
u32 c;
u32 addr = 0xE000400C;
u32 gpiov;
u32 lcddataadd = 0x6200F002;
u32 cnt=1;
__asm
{
LDR gpiov, [addr]
ORR gpiov,gpiov,1
STR gpiov,[addr]
LOOP:
SUBS cnt,cnt,#1
BNE LOOP
LDRB c,[lcddataadd]
MOV cnt,#2
LOOP1:
SUBS cnt,cnt,#1
BNE LOOP1
BIC gpiov,gpiov,1
STR gpiov,[addr]
}
#endif
#ifndef ASSEMBAL
char c;
LCD_SET_A0();
LCD_CLR_CS();
c = LCDPortData;
LCD_SET_CS();
LCD_CLR_A0();
#endif
return (u8)c;
}
/* Write CMD to controller 0, with A0 = 0, CS1 = 0*/
void LCD_X_Write00(char c) {
#ifdef ASSEMBAL
u32 addr = 0xE000400C;
u32 gpiov;
u32 lcddataadd = 0x6200F000;
__asm
{
LDR gpiov, [addr]
BIC gpiov,gpiov,1
STR gpiov,[addr]
NOP //NOP的个数很关键
STRB c,[lcddataadd]
ORR gpiov,gpiov,1
STR gpiov,[addr]
}
#endif
#ifndef ASSEMBAL
LCD_CLR_A0();
LCD_CLR_CS();
LCDPortCmd = c;
LCD_SET_CS();
LCD_SET_A0();
#endif
}
/* Write DATA to controller 0, with A0 = 1, CS1 = 0 */
void LCD_X_Write01(char c) {
#ifdef ASSEMBAL
u32 addr = 0xE000400C;
u32 gpiov;
u32 lcddataadd = 0x6200F002;
__asm
{
LDR gpiov, [addr]
ORR gpiov,gpiov,1
STR gpiov,[addr]
NOP
STRB c,[lcddataadd]
BIC gpiov,gpiov,1
STR gpiov,[addr]
}
#endif
#ifndef ASSEMBAL
LCD_SET_A0();
LCD_CLR_CS();
LCDPortData = c;
LCD_SET_CS();
LCD_CLR_A0();
#endif
}
/******************* (C) COPYRIGHT 千能电力 *****END OF FILE*******************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -