📄 xlcd.h
字号:
/**********************************************************************
* *
* Software License Agreement *
* *
* The software supplied herewith by Microchip Technology *
* Incorporated (the "Company") for its dsPIC controller *
* is intended and supplied to you, the Company's customer, *
* for use solely and exclusively on Microchip dsPIC *
* products. The software is owned by the Company and/or its *
* supplier, and is protected under applicable copyright laws. All *
* rights are reserved. Any use in violation of the foregoing *
* restrictions may subject the user to criminal sanctions under *
* applicable laws, as well as to civil liability for the breach of *
* the terms and conditions of this license. *
* *
* THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO *
* WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, *
* BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND *
* FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE *
* COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, *
* INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. *
* *
**********************************************************************/
/**********************************************************************
* *
* Author: Smart Power Soutions, Jorge Zambada, Alex Dumais *
* *
* Filename: xlcd.h *
* Date: 07/23/07 *
* File Version: 5.10 *
* Project: 53 *
* Drawing: 2 *
* *
* Tools used: MPLAB v7.61 C30 Compiler v 3.01 *
* *
* Linker File: p33FJ256MC710.gld *
* *
* *
***********************************************************************
* Code Description
*
* These are the definitions required for the LCD drivers.
* This file was taken from the Microchip C18 compiler library
* and modified for use on the dsPIC. In particular, the routines
* will only work using a 4-bit interface to the LCD. The 4 data
* lines must be connected to the lower nibble of a dsPIC port.
*
* Note: The LCD routines contain delay routines which must be modified
* based on the device clock frequency. As written, these routines
* work for a device instruction cycle frequency of 7.38 MHz.
*
* Notes:
* - These libraries routines are written to support the
* Hitachi HD44780 LCD controller.
* - The user must define the following items:
* - The data port
* - The tris register for data port
* - The control signal ports and pins
* - The control signal port tris and pins
* - The user must provide three delay routines:
* - DelayFor18TCY() provides a 18 Tcy delay
* - DelayPORXLCD() provides at least 15ms delay
* - DelayXLCD() provides at least 5ms delay
*
**********************************************************************/
#ifndef __XLCD_H
#define __XLCD_H
/* Interface type 8-bit or 4-bit
* For 4-bit operation uncomment the #define BIT8
*/
#define BIT8
/* When in 4-bit interface define if the data is in the upper
* or lower nibble. For lower nibble, uncomment the #define UPPER
*/
#define UPPER
/* DATA_PORT defines the port to which the LCD data lines are connected */
#define DATA_PORT PORTD
#define TRIS_DATA_PORT TRISD
/* CTRL_PORT defines the port where the control lines are connected.
* These are just samples, change to match your application.
*/
#define RW_PIN LATDbits.LATD5 /* PORT for RW */
#define TRIS_RW TRISDbits.TRISD5 /* TRIS for RW */
#define RS_PIN LATBbits.LATB15 /* PORT for RS */
#define TRIS_RS TRISBbits.TRISB15 /* TRIS for RS */
#define E_PIN LATDbits.LATD4 /* PORT for E */
#define TRIS_E TRISDbits.TRISD4 /* TRIS for E */
/* Display ON/OFF Control defines */
#define DON 0x0f /* Display on */
#define DOFF 0x0b /* Display off */
#define CURSOR_ON 0x0f /* Cursor on */
#define CURSOR_OFF 0x0d /* Cursor off */
#define BLINK_ON 0x0f /* Cursor Blink */
#define BLINK_OFF 0x0e /* Cursor No Blink */
/* Cursor or Display Shift defines */
#define SHIFT_CUR_LEFT 0x13 /* Cursor shifts to the left */
#define SHIFT_CUR_RIGHT 0x17 /* Cursor shifts to the right */
#define SHIFT_DISP_LEFT 0x1b /* Display shifts to the left */
#define SHIFT_DISP_RIGHT 0x1f /* Display shifts to the right */
/* Function Set defines */
#define FOUR_BIT 0x2f /* 4-bit Interface */
#define EIGHT_BIT 0x3f /* 8-bit Interface */
#define LINE_5X7 0x33 /* 5x7 characters, single line */
#define LINE_5X10 0x37 /* 5x10 characters */
#define LINES_5X7 0x38 /* 5x7 characters, multiple line */
/* OpenXLCD
* Configures I/O pins for external LCD
*/
void OpenXLCD(unsigned char);
/* SetCGRamAddr
* Sets the character generator address
*/
void SetCGRamAddr(unsigned char);
/* SetDDRamAddr
* Sets the display data address
*/
void SetDDRamAddr(unsigned char);
/* BusyXLCD
* Returns the busy status of the LCD
*/
unsigned char BusyXLCD(void);
/* ReadAddrXLCD
* Reads the current address
*/
unsigned char ReadAddrXLCD(void);
/* ReadDataXLCD
* Reads a byte of data
*/
char ReadDataXLCD(void);
/* WriteCmdXLCD
* Writes a command to the LCD
*/
void WriteCmdXLCD(unsigned char);
/* WriteDataXLCD
* Writes a data byte to the LCD
*/
void WriteDataXLCD( unsigned char);
/* putcXLCD
* A putc is a write
*/
#define putcXLCD WriteDataXLCD
/* putsXLCD
* Writes a string of characters to the LCD
*/
void putsXLCD(unsigned const char *);
/* User defines these routines according to the oscillator frequency */
void DelayFor18TCY(void);
void DelayPORXLCD(void);
void DelayXLCD(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -