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

📄 lcdiof.h

📁 ST7032i驱动应用实例(I2C接口)
💻 H
字号:
// ------------------------ Header file for lcdiof.c ---------------------------
#ifndef __LCD_DATA__IO__
#define __LCD_DATA__IO__

// ------------------------ Interface Selection --------------------------------
//#define LCD_READABLE		// If LCD-Reading is possible & needed, define it!
//#define MCU_6800_8BIT		// 6800 MCU 8-bit Parallel
//#define MCU_6800_4BIT		// 6800 MCU 4-bit Parallel
//#define MCU_8080_8BIT		// 8080 MCU 8-bit Parallel
//#define MCU_8080_4BIT		// 8080 MCU 4-bit Parallel
//#define LCD_4SPI			// 4-wire SPI(A-Type)(S8)
//#define LCD_3SPI			// 3-wire SPI(S9)
#define LCD_I2C			// I2C Interface

// --------------------------- Pins Definition ---------------------------------
// Common Pins for all interface(IC Specific!)
#define __PORT_CONFIG__
#ifdef __PORT_CONFIG__
	#define LCD_BM1			0
	#define LCD_BM0			1
	#define LCD_SM1			7	// Serial Mode 1
	#define LCD_SM0			6	// Serial Mode 0
	#define LCD_WR1			6
	#define LCD_WR0			5
#endif

#define LCD_CtrlPort	PORTB
#define LCD_DataPort	PORTB
#define LCD_CtrlPort_DDR	DDRB
#define LCD_DataPort_DDR	DDRB
#define LCD_DataPins	PINB

// Special Pins for the specific interface
#if ((defined(MCU_6800_8BIT)) || (defined(MCU_6800_4BIT)))
	// 6800 MCU 8/4-bit Parallel
	#define LCD_CS	    	2	// Chip Selection
	#define LCD_RST    		3	// Reset
	#define LCD_A0	    	4	// Data/Command Register Selection(LCD_RS)
	#define LCD_RW      	5	// Read/Write
	#define LCD_E			6	// Enable R/W	
#elif ((defined(MCU_8080_8BIT)) || (defined(MCU_8080_4BIT)))
	// 8080 MCU 8/4-bit Parallel
	#define LCD_CS	    	2	// Chip Selection
	#define LCD_RST    		3	// Reset
	#define LCD_A0	    	4	// Data/Command Register Selection
	#define LCD_WR      	5	// Read/Write
	#define LCD_RD			6	// Enable R/W
#elif defined(LCD_4SPI)
	// 4-wire SPI(A-Type)	
	#define SPI_CLK			0	// Serial Clock
	#define SPI_MOSI		1	// Serial Instructions and data(LCD_SDIN)
	//#define SPI_MISO		6	// Serial Instructions and data(LCD_SDOUT)	
	#define LCD_CS			2	// Chip Selection
	#define LCD_RST			3	// Reset
	#define LCD_A0			4	// Data/Command Register Selection
	#include "spi.h"
#elif defined(LCD_3SPI)
	// 3-wire SPI
	#define SPI_CLK			7	// Serial Clock
	//#define SPI_MISO		6	// Serial data input
	#define SPI_MOSI		5	// Serial Instructions and data(LCD_SDIN)
	#define LCD_CS			4	// Chip Selection
	#define LCD_RST			3	// Reset
	#include "spi.h"
#elif defined(LCD_I2C)
	// I2C Interface
	#define I2C_DataPort	LCD_DataPort
	#define I2C_DataPins	LCD_DataPins
	#define I2C_SCL		0		// LCD SCL
	#define I2C_SDA		1		// LCD SDA
	#define LCD_RST		2		// LCD Reset
	#define LCD_I2C_ADDR	0x7C	// Slave Address of the LCM: 0111 110(R/W)
	#include "i2c.h"
#endif
// -----------------------------------------------------------------------------

// -------------------------- Constants definition -----------------------------
#define iDat	1
#define iCmd	0
// LCD_Enable/Disable Macros
#ifdef LCD_CS
	#define LCD_Enable()	cbi(LCD_CtrlPort, LCD_CS)
	#define LCD_Disable()	sbi(LCD_CtrlPort, LCD_CS)
#endif
// -----------------------------------------------------------------------------

// --------------------------- Functions Declaration ---------------------------
#ifdef __PORT_CONFIG__
	// Port configuration of MCU
	void PortConfig(void);
#endif
#ifdef LCD_RST
	// Reset LCD
	void LCD_Reset(void);
#endif
// Send a data or command to LCD
void SendByte(uint8 DatCmd, uint8 dByte);
#ifdef LCD_READABLE
	// Read a data from LCD DDRAM
	// Page Address & Column Address should be set at first.
	// E.G. Gotoxy(PAddr, CAddr);
	uint8 LCD_ReadData(void);
	// Send a byte overlayed with the orginal data
	void AndByte(uint8 dByte);
#endif
// Write a Byte of data to the LCD
void LCD_WriteData(uint8 dByte);
// -----------------------------------------------------------------------------

#include "lcdiof.c"
#endif

⌨️ 快捷键说明

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