Initial code for lab 3

This commit is contained in:
David Lenfesty 2019-10-22 12:26:26 -06:00
parent fc74d91557
commit fe908f3317
16 changed files with 3941 additions and 37 deletions

View File

@ -1,8 +1,8 @@
# Fdb version 3
["pdflatex"] 1571094986 "/home/david/Documents/homework/ECE_312/lab/lab_2/report.tex" "/home/david/Documents/homework/ECE_312/lab/lab_2/report.pdf" "report" 1571094987
["pdflatex"] 1571763854 "/home/david/Documents/homework/ECE_312/lab/lab_2/report.tex" "/home/david/Documents/homework/ECE_312/lab/lab_2/report.pdf" "report" 1571763856
"/etc/texmf/web2c/texmf.cnf" 1567530603 475 c0e671620eb5563b2130f56340a5fde8 ""
"/home/david/Documents/homework/ECE_312/lab/lab_2/report.aux" 1571094986 1101 1a30b85b54e6101e6788286e2d2e7d17 ""
"/home/david/Documents/homework/ECE_312/lab/lab_2/report.tex" 1571094984 3014 3a4851ebeb75343421edf4abaf2e0061 ""
"/home/david/Documents/homework/ECE_312/lab/lab_2/report.aux" 1571763856 1101 1a30b85b54e6101e6788286e2d2e7d17 ""
"/home/david/Documents/homework/ECE_312/lab/lab_2/report.tex" 1571763852 2878 8a0466ce1c1444c68616666c8ed66266 ""
"/usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map" 1511824771 3332 103109f5612ad95229751940c61aada0 ""
"/usr/share/texlive/texmf-dist/fonts/tfm/public/amsfonts/cmextra/cmex7.tfm" 1480098698 1004 54797486969f23fa377b128694d548df ""
"/usr/share/texlive/texmf-dist/fonts/tfm/public/amsfonts/cmextra/cmex8.tfm" 1480098698 988 bdf658c3bfc2d96d3c8b02cfc1c94c20 ""
@ -84,17 +84,17 @@
"/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty" 1480098843 55589 34128738f682d033422ca125f82e5d62 ""
"/usr/share/texlive/texmf-dist/web2c/texmf.cnf" 1520210507 32485 c64754543d8ac501bea6e75e209ea521 ""
"/usr/share/texmf/web2c/texmf.cnf" 1520210507 32485 c64754543d8ac501bea6e75e209ea521 ""
"/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map" 1568140038 2361257 726fe6b8da9ff7c93aa3fe9e1a980b90 ""
"/var/lib/texmf/web2c/pdftex/pdflatex.fmt" 1567717912 724917 8f47dfd9e170416fd47eaec382daba57 ""
"report.aux" 1571094986 1101 1a30b85b54e6101e6788286e2d2e7d17 ""
"report.out" 1571094986 259 c3c35b14c3a91f538e188aae8cf11d7b ""
"report.tex" 1571094984 3014 3a4851ebeb75343421edf4abaf2e0061 ""
"report.toc" 1571094986 349 2e22671396011105a0637f600dfbb12c ""
"/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map" 1571178984 2398241 5e1d59013fffd6a00fd713275690e0d4 ""
"/var/lib/texmf/web2c/pdftex/pdflatex.fmt" 1571178993 813573 e4567727fdf7e1b21053a4ebc3086b19 ""
"report.aux" 1571763856 1101 1a30b85b54e6101e6788286e2d2e7d17 ""
"report.out" 1571763856 259 c3c35b14c3a91f538e188aae8cf11d7b ""
"report.tex" 1571763852 2878 8a0466ce1c1444c68616666c8ed66266 ""
"report.toc" 1571763856 349 2e22671396011105a0637f600dfbb12c ""
(generated)
"report.pdf"
"/home/david/Documents/homework/ECE_312/lab/lab_2/report.log"
"report.log"
"report.aux"
"report.toc"
"report.pdf"
"report.out"
"report.log"
"report.toc"
"/home/david/Documents/homework/ECE_312/lab/lab_2/report.log"
"/home/david/Documents/homework/ECE_312/lab/lab_2/report.pdf"

View File

@ -1,4 +1,4 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex 2019.9.5) 14 OCT 2019 17:16
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex 2019.10.15) 22 OCT 2019 11:04
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
@ -6,7 +6,7 @@ entering extended mode
**/home/david/Documents/homework/ECE_312/lab/lab_2/report.tex
(/home/david/Documents/homework/ECE_312/lab/lab_2/report.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 3 language(s) loaded.
Babel <3.18> and hyphenation patterns for 7 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo
@ -417,29 +417,29 @@ File: umsb.fd 2013/01/14 v3.01 AMS symbols B
\openout5 = `report.toc'.
[2] [1] [2]
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 132.
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 127.
[3]
Package atveryend Info: Empty hook `AfterLastShipout' on input line 132.
Package atveryend Info: Empty hook `AfterLastShipout' on input line 127.
(/home/david/Documents/homework/ECE_312/lab/lab_2/report.aux)
Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 132.
Package atveryend Info: Executing hook `AtEndAfterFileList' on input line 132.
Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 127.
Package atveryend Info: Executing hook `AtEndAfterFileList' on input line 127.
Package rerunfilecheck Info: File `report.out' has not changed.
(rerunfilecheck) Checksum: C3C35B14C3A91F538E188AAE8CF11D7B;259.
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 132.
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 127.
)
Here is how much of TeX's memory you used:
8854 strings out of 494923
128188 string characters out of 6180743
231498 words of memory out of 5000000
11996 multiletter control sequences out of 15000+600000
8849 strings out of 494847
128113 string characters out of 6179079
231743 words of memory out of 5000000
12005 multiletter control sequences out of 15000+600000
12564 words of font info for 49 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
59 hyphenation exceptions out of 8191
37i,9n,39p,318b,1628s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/symbols/msam10.pfb>
Output written on /home/david/Documents/homework/ECE_312/lab/lab_2/report.pdf (5 pages, 70304 bytes).
Output written on /home/david/Documents/homework/ECE_312/lab/lab_2/report.pdf (5 pages, 69895 bytes).
PDF statistics:
140 PDF objects out of 1000 (max. 8388607)
125 compressed objects within 2 object streams
59 named destinations out of 1000 (max. 500000)
134 PDF objects out of 1000 (max. 8388607)
119 compressed objects within 2 object streams
54 named destinations out of 1000 (max. 500000)
41 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

Binary file not shown.

View File

@ -87,11 +87,6 @@ main():
reset flag playing
play_rest()
// Will play rest of current beat then shut off
button_press_interrupt():
disable_interrupts()
set flag interrupt_button_press
// Plays one full beat
play_beat():
if current_note_has_duration:

Binary file not shown.

334
lab_3/lcdlibrary/Makefile Normal file
View File

@ -0,0 +1,334 @@
# ----------------------------------------------------------------------------
# Makefile for lcd library
# Author: Peter Fleury
# File: $Id: Makefile.lcd,v 1.5 2015/01/31 19:59:32 peter Exp $
#
# Adjust MCU and F_CPU below to your AVR target
# Optionally define -D_LCD_DEFINITIONS_FILE in the CDEFS section below
# if you want to use a separate file for display and target specific defines
#----------------------------------------------------------------------------
# usage:
#
# make = build software
# make clean = Clean out built project files
# make program = Download the hex file to the device, using avrdude.
# Please customize the avrdude settings below first!
#
# make filename.s = Just compile filename.c into the assembler code only.
# make filename.i = Create a preprocessed source file
#
# To rebuild project do "make clean" then "make"
#----------------------------------------------------------------------------
# MCU name
MCU = atmega16
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
F_CPU = 4000000
# Target file name (without extension).
TARGET = test_lcd
# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c lcd.c
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
#ASRC =
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
# Use forward slashes for directory separators.
# For a directory that has spaces, enclose it in quotes.
EXTRAINCDIRS =
#specify alternate location of sources files
# (unlike VPATH= which is a search path for all prerequisites, not just source files)
#vpath %.c <directory>
#vpath %.S <directory>
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
# Place -D or -U options here
# Uncomment below line if you want to use a separate file lcd_definitions.h
# for display and target specific definitions
#CDEFS = -D_LCD_DEFINITIONS_FILE
# Place -I options here
CINCS =
#---------------- Compiler Options ----------------
# -gdwarf-2: generate debugging information
# -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing
CFLAGS = -DF_CPU=$(F_CPU)UL
CFLAGS += $(CDEFS) $(CINCS)
CFLAGS += -I. $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += -std=gnu99
CFLAGS += -gdwarf-2
CFLAGS += -O$(OPT)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
CFLAGS += -save-temps
#---------------- Assembler Options ----------------
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns=$(<:.S=.lst) create listing
# -gdwarf-2: generate debugging information
ASFLAGS = -DF_CPU=$(F_CPU)UL -x assembler-with-cpp -Wa,-gdwarf2
#---------------- Library Options ----------------
# Minimalistic printf version
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
# Floating point printf version (requires MATH_LIB = -lm below)
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
# If this is left blank, then it will use the Standard printf version.
PRINTF_LIB =
#PRINTF_LIB = $(PRINTF_LIB_MIN)
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
# Minimalistic scanf version
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
# If this is left blank, then it will use the Standard scanf version.
SCANF_LIB =
#SCANF_LIB = $(SCANF_LIB_MIN)
#SCANF_LIB = $(SCANF_LIB_FLOAT)
MATH_LIB = -lm
#---------------- External Memory Options ----------------
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
# used for variables (.data/.bss) and heap (malloc()).
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
# only used for heap (malloc()).
#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
EXTMEMOPTS =
#---------------- Linker Options ----------------
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += $(EXTMEMOPTS)
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
#---------------- Programming Options (avrdude) ----------------
# Programming hardware: Type: avrdude -c ? to get a full listing.
AVRDUDE_PROGRAMMER = usbasp
# usb, com1 = serial port, lpt1 = parallel port
AVRDUDE_PORT = USB
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
# Uncomment the following if you do /not/ wish a verification to be performed after programming the device.
#AVRDUDE_NO_VERIFY = -V
# Disable save mode for fuses
AVRDUDE_NO_SAFEMODE = -u
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
#AVRDUDE_ERASE_COUNTER = -y
# Increase verbosity level.
#AVRDUDE_VERBOSE = -v -v
# Adjust programming speed of USBasp
# no -B switch 375khz (default)
# -B 2000 500 hz
# -B 1000 1khz
# -B 500 2khz
# -B 250 4khz
# -B 125 8 khz
# -B 62 16khz
# -B 31 32khz * the cutoff for bit banged isp
# -B 10 93.75 khz
# -B 5 187.5 khz
# -B 2 375 khz
# -B 1 750 khz
# -B .5 1.5mhz
AVRDUDE_SPEED = -B .5
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_NO_SAFEMODE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
AVRDUDE_FLAGS += $(AVRDUDE_SPEED)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
#============================================================================
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Define programs and commands.
#SHELL = win-bash
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
NM = avr-nm
AVRDUDE = avrdude
REMOVE = rm -rf
COPY = cp
WINSHELL = cmd
# Define Messages
MSG_FLASH = Creating load file for Flash:
MSG_EEPROM = Creating load file for EEPROM:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling:
MSG_ASSEMBLING = Assembling:
MSG_CLEANING = Cleaning project:
# Define all object files.
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
# Define all listing files.
LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
# Compiler flags to generate dependency files.
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mmcu=$(MCU) $(CFLAGS) $(GENDEPFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. $(ASFLAGS)
# Default target.
all: gccversion $(TARGET).elf $(TARGET).hex $(TARGET).eep $(TARGET).lss $(TARGET).sym size
# Display compiler version information.
gccversion :
@echo $(OBJ1)
@$(CC) --version
# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
%.eep: %.elf
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
%.lss: %.elf
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S $< > $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo $(MSG_SYMBOL_TABLE) $@
$(NM) -n $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
@echo $(MSG_LINKING) $@
$(CC) -mmcu=$(MCU) $(LDFLAGS) $^ --output $(@F)
# Compile: create object files from C source files.
%.o : %.c
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $< -o $(@F)
# Compile: create assembler files from C source files.
%.s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $(@F)
# Assemble: create object files from assembler source files.
%.o : %.S
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $(@F)
# Create preprocessed source for use in sending a bug report.
%.i : %.c
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $(@F)
# Display size of file.
size: ${TARGET}.elf
@avr-size -C --mcu=${MCU} ${TARGET}.elf
# Program the device.
program: $(TARGET).hex $(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
# Delete all generated files.
clean:
@echo $(MSG_CLEANING)
$(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf $(TARGET).map $(TARGET).sym $(TARGET).lss $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(SRC:.c=.i) .dep/
# Include the dependency files.
#-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-include $(shell mkdir .dep 2>NUL) $(wildcard .dep/*)
# Listing of phony targets.
.PHONY : all size gccversion clean program

1449
lab_3/lcdlibrary/doxygen.css Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

592
lab_3/lcdlibrary/lcd.c Normal file
View File

@ -0,0 +1,592 @@
/****************************************************************************
Title: HD44780U LCD library
Author: Peter Fleury <pfleury@gmx.ch> http://tinyurl.com/peterfleury
File: $Id: lcd.c,v 1.15.2.2 2015/01/17 12:16:05 peter Exp $
Software: AVR-GCC 3.3
Target: any AVR device, memory mapped mode only for AT90S4414/8515/Mega
DESCRIPTION
Basic routines for interfacing a HD44780U-based text lcd display
Originally based on Volker Oth's lcd library,
changed lcd_init(), added additional constants for lcd_command(),
added 4-bit I/O mode, improved and optimized code.
Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in
4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported.
Memory mapped mode compatible with Kanda STK200, but supports also
generation of R/W signal through A8 address line.
USAGE
See the C include lcd.h file for a description of each function
*****************************************************************************/
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "lcd.h"
/*
** constants/macros
*/
#define DDR(x) (*(&x - 1)) /* address of data direction register of port x */
#if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
/* on ATmega64/128 PINF is on port 0x00 and not 0x60 */
#define PIN(x) ( &PORTF==&(x) ? _SFR_IO8(0x00) : (*(&x - 2)) )
#else
#define PIN(x) (*(&x - 2)) /* address of input register of port x */
#endif
#if LCD_IO_MODE
#define lcd_e_delay() _delay_us(LCD_DELAY_ENABLE_PULSE)
#define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN);
#define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN);
#define lcd_e_toggle() toggle_e()
#define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN)
#define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN)
#define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN)
#define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN)
#endif
#if LCD_IO_MODE
#if LCD_LINES==1
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE
#else
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES
#endif
#else
#if LCD_LINES==1
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE
#else
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES
#endif
#endif
#if LCD_CONTROLLER_KS0073
#if LCD_LINES==4
#define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x2C /* |0|010|1100 4-bit mode, extension-bit RE = 1 */
#define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x28 /* |0|010|1000 4-bit mode, extension-bit RE = 0 */
#define KS0073_4LINES_MODE 0x09 /* |0|000|1001 4 lines mode */
#endif
#endif
/*
** function prototypes
*/
#if LCD_IO_MODE
static void toggle_e(void);
#endif
/*
** local functions
*/
/*************************************************************************
delay for a minimum of <us> microseconds
the number of loops is calculated at compile-time from MCU clock frequency
*************************************************************************/
#define delay(us) _delay_us(us)
#if LCD_IO_MODE
/* toggle Enable Pin to initiate write */
static void toggle_e(void)
{
lcd_e_high();
lcd_e_delay();
lcd_e_low();
}
#endif
/*************************************************************************
Low-level function to write byte to LCD controller
Input: data byte to write to LCD
rs 1: write data
0: write instruction
Returns: none
*************************************************************************/
#if LCD_IO_MODE
static void lcd_write(uint8_t data,uint8_t rs)
{
unsigned char dataBits ;
if (rs) { /* write data (RS=1, RW=0) */
lcd_rs_high();
} else { /* write instruction (RS=0, RW=0) */
lcd_rs_low();
}
lcd_rw_low(); /* RW=0 write mode */
if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
&& (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
{
/* configure data pins as output */
DDR(LCD_DATA0_PORT) |= 0x0F;
/* output high nibble first */
dataBits = LCD_DATA0_PORT & 0xF0;
LCD_DATA0_PORT = dataBits |((data>>4)&0x0F);
lcd_e_toggle();
/* output low nibble */
LCD_DATA0_PORT = dataBits | (data&0x0F);
lcd_e_toggle();
/* all data pins high (inactive) */
LCD_DATA0_PORT = dataBits | 0x0F;
}
else
{
/* configure data pins as output */
DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
/* output high nibble first */
LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);
LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);
LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);
if(data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
if(data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
if(data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
if(data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
lcd_e_toggle();
/* output low nibble */
LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);
LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);
LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);
if(data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
if(data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
if(data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
if(data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
lcd_e_toggle();
/* all data pins high (inactive) */
LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
}
}
#else
#define lcd_write(d,rs) if (rs) *(volatile uint8_t*)(LCD_IO_DATA) = d; else *(volatile uint8_t*)(LCD_IO_FUNCTION) = d;
/* rs==0 -> write instruction to LCD_IO_FUNCTION */
/* rs==1 -> write data to LCD_IO_DATA */
#endif
/*************************************************************************
Low-level function to read byte from LCD controller
Input: rs 1: read data
0: read busy flag / address counter
Returns: byte read from LCD controller
*************************************************************************/
#if LCD_IO_MODE
static uint8_t lcd_read(uint8_t rs)
{
uint8_t data;
if (rs)
lcd_rs_high(); /* RS=1: read data */
else
lcd_rs_low(); /* RS=0: read busy flag */
lcd_rw_high(); /* RW=1 read mode */
if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
&& ( LCD_DATA0_PIN == 0 )&& (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
{
DDR(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */
lcd_e_high();
lcd_e_delay();
data = PIN(LCD_DATA0_PORT) << 4; /* read high nibble first */
lcd_e_low();
lcd_e_delay(); /* Enable 500ns low */
lcd_e_high();
lcd_e_delay();
data |= PIN(LCD_DATA0_PORT)&0x0F; /* read low nibble */
lcd_e_low();
}
else
{
/* configure data pins as input */
DDR(LCD_DATA0_PORT) &= ~_BV(LCD_DATA0_PIN);
DDR(LCD_DATA1_PORT) &= ~_BV(LCD_DATA1_PIN);
DDR(LCD_DATA2_PORT) &= ~_BV(LCD_DATA2_PIN);
DDR(LCD_DATA3_PORT) &= ~_BV(LCD_DATA3_PIN);
/* read high nibble first */
lcd_e_high();
lcd_e_delay();
data = 0;
if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x10;
if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x20;
if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x40;
if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x80;
lcd_e_low();
lcd_e_delay(); /* Enable 500ns low */
/* read low nibble */
lcd_e_high();
lcd_e_delay();
if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x01;
if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x02;
if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x04;
if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x08;
lcd_e_low();
}
return data;
}
#else
#define lcd_read(rs) (rs) ? *(volatile uint8_t*)(LCD_IO_DATA+LCD_IO_READ) : *(volatile uint8_t*)(LCD_IO_FUNCTION+LCD_IO_READ)
/* rs==0 -> read instruction from LCD_IO_FUNCTION */
/* rs==1 -> read data from LCD_IO_DATA */
#endif
/*************************************************************************
loops while lcd is busy, returns address counter
*************************************************************************/
static uint8_t lcd_waitbusy(void)
{
register uint8_t c;
/* wait until busy flag is cleared */
while ( (c=lcd_read(0)) & (1<<LCD_BUSY)) {}
/* the address counter is updated 4us after the busy flag is cleared */
delay(LCD_DELAY_BUSY_FLAG);
/* now read the address counter */
return (lcd_read(0)); // return address counter
}/* lcd_waitbusy */
/*************************************************************************
Move cursor to the start of next line or to the first line if the cursor
is already on the last line.
*************************************************************************/
static inline void lcd_newline(uint8_t pos)
{
register uint8_t addressCounter;
#if LCD_LINES==1
addressCounter = 0;
#endif
#if LCD_LINES==2
if ( pos < (LCD_START_LINE2) )
addressCounter = LCD_START_LINE2;
else
addressCounter = LCD_START_LINE1;
#endif
#if LCD_LINES==4
#if KS0073_4LINES_MODE
if ( pos < LCD_START_LINE2 )
addressCounter = LCD_START_LINE2;
else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE3) )
addressCounter = LCD_START_LINE3;
else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4) )
addressCounter = LCD_START_LINE4;
else
addressCounter = LCD_START_LINE1;
#else
if ( pos < LCD_START_LINE3 )
addressCounter = LCD_START_LINE2;
else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4) )
addressCounter = LCD_START_LINE3;
else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2) )
addressCounter = LCD_START_LINE4;
else
addressCounter = LCD_START_LINE1;
#endif
#endif
lcd_command((1<<LCD_DDRAM)+addressCounter);
}/* lcd_newline */
/*
** PUBLIC FUNCTIONS
*/
/*************************************************************************
Send LCD controller instruction command
Input: instruction to send to LCD controller, see HD44780 data sheet
Returns: none
*************************************************************************/
void lcd_command(uint8_t cmd)
{
lcd_waitbusy();
lcd_write(cmd,0);
}
/*************************************************************************
Send data byte to LCD controller
Input: data to send to LCD controller, see HD44780 data sheet
Returns: none
*************************************************************************/
void lcd_data(uint8_t data)
{
lcd_waitbusy();
lcd_write(data,1);
}
/*************************************************************************
Set cursor to specified position
Input: x horizontal position (0: left most position)
y vertical position (0: first line)
Returns: none
*************************************************************************/
void lcd_gotoxy(uint8_t x, uint8_t y)
{
#if LCD_LINES==1
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
#endif
#if LCD_LINES==2
if ( y==0 )
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
else
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
#endif
#if LCD_LINES==4
if ( y==0 )
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
else if ( y==1)
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
else if ( y==2)
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE3+x);
else /* y==3 */
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE4+x);
#endif
}/* lcd_gotoxy */
/*************************************************************************
*************************************************************************/
int lcd_getxy(void)
{
return lcd_waitbusy();
}
/*************************************************************************
Clear display and set cursor to home position
*************************************************************************/
void lcd_clrscr(void)
{
lcd_command(1<<LCD_CLR);
}
/*************************************************************************
Set cursor to home position
*************************************************************************/
void lcd_home(void)
{
lcd_command(1<<LCD_HOME);
}
/*************************************************************************
Display character at current cursor position
Input: character to be displayed
Returns: none
*************************************************************************/
void lcd_putc(char c)
{
uint8_t pos;
pos = lcd_waitbusy(); // read busy-flag and address counter
if (c=='\n')
{
lcd_newline(pos);
}
else
{
#if LCD_WRAP_LINES==1
#if LCD_LINES==1
if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
}
#elif LCD_LINES==2
if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0);
}else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ){
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
}
#elif LCD_LINES==4
if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0);
}else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ) {
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE3,0);
}else if ( pos == LCD_START_LINE3+LCD_DISP_LENGTH ) {
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE4,0);
}else if ( pos == LCD_START_LINE4+LCD_DISP_LENGTH ) {
lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
}
#endif
lcd_waitbusy();
#endif
lcd_write(c, 1);
}
}/* lcd_putc */
/*************************************************************************
Display string without auto linefeed
Input: string to be displayed
Returns: none
*************************************************************************/
void lcd_puts(const char *s)
/* print string on lcd (no auto linefeed) */
{
register char c;
while ( (c = *s++) ) {
lcd_putc(c);
}
}/* lcd_puts */
/*************************************************************************
Display string from program memory without auto linefeed
Input: string from program memory be be displayed
Returns: none
*************************************************************************/
void lcd_puts_p(const char *progmem_s)
/* print string from program memory on lcd (no auto linefeed) */
{
register char c;
while ( (c = pgm_read_byte(progmem_s++)) ) {
lcd_putc(c);
}
}/* lcd_puts_p */
/*************************************************************************
Initialize display and select type of cursor
Input: dispAttr LCD_DISP_OFF display off
LCD_DISP_ON display on, cursor off
LCD_DISP_ON_CURSOR display on, cursor on
LCD_DISP_CURSOR_BLINK display on, cursor on flashing
Returns: none
*************************************************************************/
void lcd_init(uint8_t dispAttr)
{
#if LCD_IO_MODE
/*
* Initialize LCD to 4 bit I/O mode
*/
if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
&& ( &LCD_RS_PORT == &LCD_DATA0_PORT) && ( &LCD_RW_PORT == &LCD_DATA0_PORT) && (&LCD_E_PORT == &LCD_DATA0_PORT)
&& (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)
&& (LCD_RS_PIN == 4 ) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6 ) )
{
/* configure all port bits as output (all LCD lines on same port) */
DDR(LCD_DATA0_PORT) |= 0x7F;
}
else if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
&& (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
{
/* configure all port bits as output (all LCD data lines on same port, but control lines on different ports) */
DDR(LCD_DATA0_PORT) |= 0x0F;
DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
}
else
{
/* configure all port bits as output (LCD data and control lines on different ports */
DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
}
delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */
/* initial write to lcd is 8bit */
LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4;
LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4;
lcd_e_toggle();
delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */
/* repeat last command */
lcd_e_toggle();
delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
/* repeat last command a third time */
lcd_e_toggle();
delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
/* now configure for 4bit mode */
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4
lcd_e_toggle();
delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */
/* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */
#else
/*
* Initialize LCD to 8 bit memory mapped mode
*/
/* enable external SRAM (memory mapped lcd) and one wait state */
MCUCR = _BV(SRE) | _BV(SRW);
/* reset LCD */
delay(LCD_DELAY_BOOTUP); /* wait 16ms after power-on */
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
delay(LCD_DELAY_INIT); /* wait 5ms */
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
delay(LCD_DELAY_INIT_REP); /* wait 64us */
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
delay(LCD_DELAY_INIT_REP); /* wait 64us */
#endif
#if KS0073_4LINES_MODE
/* Display with KS0073 controller requires special commands for enabling 4 line mode */
lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON);
lcd_command(KS0073_4LINES_MODE);
lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF);
#else
lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */
#endif
lcd_command(LCD_DISP_OFF); /* display off */
lcd_clrscr(); /* display clear */
lcd_command(LCD_MODE_DEFAULT); /* set entry mode */
lcd_command(dispAttr); /* display/cursor control */
}/* lcd_init */

369
lab_3/lcdlibrary/lcd.h Normal file
View File

@ -0,0 +1,369 @@
#ifndef LCD_H
#define LCD_H
/*************************************************************************
Title : C include file for the HD44780U LCD library (lcd.c)
Author: Peter Fleury <pfleury@gmx.ch> http://tinyurl.com/peterfleury
File: $Id: lcd.h,v 1.14.2.4 2015/01/20 17:16:07 peter Exp $
Software: AVR-GCC 4.x
Hardware: any AVR device, memory mapped mode only for AVR with
memory mapped interface (AT90S8515/ATmega8515/ATmega128)
***************************************************************************/
/**
@mainpage
Collection of libraries for AVR-GCC
@author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury
@copyright (C) 2015 Peter Fleury, GNU General Public License Version 3
@file
@defgroup pfleury_lcd LCD library <lcd.h>
@code #include <lcd.h> @endcode
@brief Basic routines for interfacing a HD44780U-based character LCD display
LCD character displays can be found in many devices, like espresso machines, laser printers.
The Hitachi HD44780 controller and its compatible controllers like Samsung KS0066U have become an industry standard for these types of displays.
This library allows easy interfacing with a HD44780 compatible display and can be
operated in memory mapped mode (LCD_IO_MODE defined as 0 in the include file lcd.h.) or in
4-bit IO port mode (LCD_IO_MODE defined as 1). 8-bit IO port mode is not supported.
Memory mapped mode is compatible with old Kanda STK200 starter kit, but also supports
generation of R/W signal through A8 address line.
@see The chapter <a href=" http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html" target="_blank">Interfacing a HD44780 Based LCD to an AVR</a>
on my home page, which shows example circuits how to connect an LCD to an AVR controller.
@author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury
@version 2.0
@copyright (C) 2015 Peter Fleury, GNU General Public License Version 3
*/
#include <inttypes.h>
#include <avr/pgmspace.h>
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 405
#error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !"
#endif
/**@{*/
/*
* LCD and target specific definitions below can be defined in a separate include file with name lcd_definitions.h instead modifying this file
* by adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
*/
#ifdef _LCD_DEFINITIONS_FILE
#include "lcd_definitions.h"
#endif
/**
* @name Definition for LCD controller type
* Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller.
*/
#ifndef LCD_CONTROLLER_KS0073
#define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */
#endif
/**
* @name Definitions for Display Size
* Change these definitions to adapt setting to your display
*
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
* adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile.
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
*
*/
#ifndef LCD_LINES
#define LCD_LINES 2 /**< number of visible lines of the display */
#endif
#ifndef LCD_DISP_LENGTH
#define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */
#endif
#ifndef LCD_LINE_LENGTH
#define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */
#endif
#ifndef LCD_START_LINE1
#define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */
#endif
#ifndef LCD_START_LINE2
#define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */
#endif
#ifndef LCD_START_LINE3
#define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */
#endif
#ifndef LCD_START_LINE4
#define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */
#endif
#ifndef LCD_WRAP_LINES
#define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */
#endif
/**
* @name Definitions for 4-bit IO mode
*
* The four LCD data lines and the three control lines RS, RW, E can be on the
* same port or on different ports.
* Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on
* different ports.
*
* Normally the four data lines should be mapped to bit 0..3 on one port, but it
* is possible to connect these data lines in different order or even on different
* ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions.
*
* Adjust these definitions to your target.\n
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
* adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile.
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
*
*/
#define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */
#if LCD_IO_MODE
#ifndef LCD_PORT
#define LCD_PORT PORTB /**< port for the LCD lines */
#endif
#ifndef LCD_DATA0_PORT
#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
#endif
#ifndef LCD_DATA1_PORT
#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
#endif
#ifndef LCD_DATA2_PORT
#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */
#endif
#ifndef LCD_DATA3_PORT
#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
#endif
#ifndef LCD_DATA0_PIN
#define LCD_DATA0_PIN 0 /**< pin for 4bit data bit 0 */
#endif
#ifndef LCD_DATA1_PIN
#define LCD_DATA1_PIN 1 /**< pin for 4bit data bit 1 */
#endif
#ifndef LCD_DATA2_PIN
#define LCD_DATA2_PIN 2 /**< pin for 4bit data bit 2 */
#endif
#ifndef LCD_DATA3_PIN
#define LCD_DATA3_PIN 3 /**< pin for 4bit data bit 3 */
#endif
#ifndef LCD_RS_PORT
#define LCD_RS_PORT LCD_PORT /**< port for RS line */
#endif
#ifndef LCD_RS_PIN
#define LCD_RS_PIN 4 /**< pin for RS line */
#endif
#ifndef LCD_RW_PORT
#define LCD_RW_PORT LCD_PORT /**< port for RW line */
#endif
#ifndef LCD_RW_PIN
#define LCD_RW_PIN 5 /**< pin for RW line */
#endif
#ifndef LCD_E_PORT
#define LCD_E_PORT LCD_PORT /**< port for Enable line */
#endif
#ifndef LCD_E_PIN
#define LCD_E_PIN 6 /**< pin for Enable line */
#endif
#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \
defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
/*
* memory mapped mode is only supported when the device has an external data memory interface
*/
#define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */
#define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */
#define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */
#else
#error "external data memory interface not available for this device, use 4-bit IO port mode"
#endif
/**
* @name Definitions of delays
* Used to calculate delay timers.
* Adapt the F_CPU define in the Makefile to the clock frequency in Hz of your target
*
* These delay times can be adjusted, if some displays require different delays.\n
* These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
* adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile.
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
*/
#ifndef LCD_DELAY_BOOTUP
#define LCD_DELAY_BOOTUP 16000 /**< delay in micro seconds after power-on */
#endif
#ifndef LCD_DELAY_INIT
#define LCD_DELAY_INIT 5000 /**< delay in micro seconds after initialization command sent */
#endif
#ifndef LCD_DELAY_INIT_REP
#define LCD_DELAY_INIT_REP 64 /**< delay in micro seconds after initialization command repeated */
#endif
#ifndef LCD_DELAY_INIT_4BIT
#define LCD_DELAY_INIT_4BIT 64 /**< delay in micro seconds after setting 4-bit mode */
#endif
#ifndef LCD_DELAY_BUSY_FLAG
#define LCD_DELAY_BUSY_FLAG 4 /**< time in micro seconds the address counter is updated after busy flag is cleared */
#endif
#ifndef LCD_DELAY_ENABLE_PULSE
#define LCD_DELAY_ENABLE_PULSE 1 /**< enable signal pulse width in micro seconds */
#endif
/**
* @name Definitions for LCD command instructions
* The constants define the various LCD controller instructions which can be passed to the
* function lcd_command(), see HD44780 data sheet for a complete description.
*/
/* instruction register bit positions, see HD44780U data sheet */
#define LCD_CLR 0 /* DB0: clear display */
#define LCD_HOME 1 /* DB1: return to home position */
#define LCD_ENTRY_MODE 2 /* DB2: set entry mode */
#define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */
#define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */
#define LCD_ON 3 /* DB3: turn lcd/cursor on */
#define LCD_ON_DISPLAY 2 /* DB2: turn display on */
#define LCD_ON_CURSOR 1 /* DB1: turn cursor on */
#define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */
#define LCD_MOVE 4 /* DB4: move cursor/display */
#define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */
#define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */
#define LCD_FUNCTION 5 /* DB5: function set */
#define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */
#define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */
#define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */
#define LCD_CGRAM 6 /* DB6: set CG RAM address */
#define LCD_DDRAM 7 /* DB7: set DD RAM address */
#define LCD_BUSY 7 /* DB7: LCD is busy */
/* set entry mode: display shift on/off, dec/inc cursor move direction */
#define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */
#define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */
#define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */
#define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */
/* display on/off, cursor on/off, blinking char at cursor position */
#define LCD_DISP_OFF 0x08 /* display off */
#define LCD_DISP_ON 0x0C /* display on, cursor off */
#define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */
#define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */
#define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */
/* move cursor/shift display */
#define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */
#define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */
#define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */
#define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */
/* function set: set interface data length and number of display lines */
#define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */
#define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */
#define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */
#define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */
#define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) )
/**
* @name Functions
*/
/**
@brief Initialize display and select type of cursor
@param dispAttr \b LCD_DISP_OFF display off\n
\b LCD_DISP_ON display on, cursor off\n
\b LCD_DISP_ON_CURSOR display on, cursor on\n
\b LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing
@return none
*/
extern void lcd_init(uint8_t dispAttr);
/**
@brief Clear display and set cursor to home position
@return none
*/
extern void lcd_clrscr(void);
/**
@brief Set cursor to home position
@return none
*/
extern void lcd_home(void);
/**
@brief Set cursor to specified position
@param x horizontal position\n (0: left most position)
@param y vertical position\n (0: first line)
@return none
*/
extern void lcd_gotoxy(uint8_t x, uint8_t y);
/**
@brief Display character at current cursor position
@param c character to be displayed
@return none
*/
extern void lcd_putc(char c);
/**
@brief Display string without auto linefeed
@param s string to be displayed
@return none
*/
extern void lcd_puts(const char *s);
/**
@brief Display string from program memory without auto linefeed
@param progmem_s string from program memory be be displayed
@return none
@see lcd_puts_P
*/
extern void lcd_puts_p(const char *progmem_s);
/**
@brief Send LCD controller instruction command
@param cmd instruction to send to LCD controller, see HD44780 data sheet
@return none
*/
extern void lcd_command(uint8_t cmd);
/**
@brief Send data byte to LCD controller
Similar to lcd_putc(), but without interpreting LF
@param data byte to send to LCD controller, see HD44780 data sheet
@return none
*/
extern void lcd_data(uint8_t data);
/**
@brief macros for automatically storing string constant in program memory
*/
#define lcd_puts_P(__s) lcd_puts_p(PSTR(__s))
/**@}*/
#endif //LCD_H

Binary file not shown.

View File

@ -0,0 +1,934 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>AVR-GCC Libraries: LCD library &lt;lcd.h&gt;</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">AVR-GCC Libraries
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">LCD library &lt;lcd.h&gt;</div> </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Basic routines for interfacing a HD44780U-based character LCD display. </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="lcd_8h.html">lcd.h</a>&gt;</span> </div>
</div><!-- fragment --><p>LCD character displays can be found in many devices, like espresso machines, laser printers. The Hitachi HD44780 controller and its compatible controllers like Samsung KS0066U have become an industry standard for these types of displays.</p>
<p>This library allows easy interfacing with a HD44780 compatible display and can be operated in memory mapped mode (LCD_IO_MODE defined as 0 in the include file <a class="el" href="lcd_8h.html">lcd.h</a>.) or in 4-bit IO port mode (LCD_IO_MODE defined as 1). 8-bit IO port mode is not supported.</p>
<p>Memory mapped mode is compatible with old Kanda STK200 starter kit, but also supports generation of R/W signal through A8 address line.</p>
<dl class="section see"><dt>See also</dt><dd>The chapter <a href=" http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html" target="_blank">Interfacing a HD44780 Based LCD to an AVR</a> on my home page, which shows example circuits how to connect an LCD to an AVR controller.</dd></dl>
<dl class="section author"><dt>Author</dt><dd>Peter Fleury <a href="#" onclick="location.href='mai'+'lto:'+'pfl'+'eu'+'ry@'+'gm'+'x.c'+'h'; return false;">pfleu<span style="display: none;">.nosp@m.</span>ry@g<span style="display: none;">.nosp@m.</span>mx.ch</a> <a href="http://tinyurl.com/peterfleury">http://tinyurl.com/peterfleury</a></dd></dl>
<dl class="section version"><dt>Version</dt><dd>2.0</dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>(C) 2015 Peter Fleury, GNU General Public License Version 3 </dd></dl>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Definition for LCD controller type</h2></td></tr>
<tr><td class="ititle" colspan="2"><p><a class="anchor" id="amgrp9cebaa2a52e46760a474a1905c7f53a9"></a>Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller. </p>
</td></tr>
<tr class="memitem:ga63574b03f72a197aeee823aae95dc3b7"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga63574b03f72a197aeee823aae95dc3b7">LCD_CONTROLLER_KS0073</a>&#160;&#160;&#160;0</td></tr>
<tr class="separator:ga63574b03f72a197aeee823aae95dc3b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Definitions for Display Size</h2></td></tr>
<tr><td class="ititle" colspan="2"><p><a class="anchor" id="amgrpcaec0cb1262819d89ffa7f25526cc869"></a>Change these definitions to adapt setting to your display</p>
<p>These definitions can be defined in a separate include file <b>lcd_definitions.h</b> instead modifying this file by adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile. All definitions added to the file lcd_definitions.h will override the default definitions from <a class="el" href="lcd_8h.html">lcd.h</a> </p>
</td></tr>
<tr class="memitem:ga01212e90283511562039db786f65ba98"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga01212e90283511562039db786f65ba98">LCD_LINES</a>&#160;&#160;&#160;2</td></tr>
<tr class="separator:ga01212e90283511562039db786f65ba98"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga684bb4392e384b7ae7c660d81dacb930"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga684bb4392e384b7ae7c660d81dacb930">LCD_DISP_LENGTH</a>&#160;&#160;&#160;16</td></tr>
<tr class="separator:ga684bb4392e384b7ae7c660d81dacb930"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae59a728d9dee9f12c817b29d38746ed9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gae59a728d9dee9f12c817b29d38746ed9">LCD_LINE_LENGTH</a>&#160;&#160;&#160;0x40</td></tr>
<tr class="separator:gae59a728d9dee9f12c817b29d38746ed9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabd056d70a1488ea2eb1aef87e248e234"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gabd056d70a1488ea2eb1aef87e248e234">LCD_START_LINE1</a>&#160;&#160;&#160;0x00</td></tr>
<tr class="separator:gabd056d70a1488ea2eb1aef87e248e234"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7b317b21058ef031716ba040ef75430a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga7b317b21058ef031716ba040ef75430a">LCD_START_LINE2</a>&#160;&#160;&#160;0x40</td></tr>
<tr class="separator:ga7b317b21058ef031716ba040ef75430a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae7cca16353048a062baeb3a52da55249"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gae7cca16353048a062baeb3a52da55249">LCD_START_LINE3</a>&#160;&#160;&#160;0x14</td></tr>
<tr class="separator:gae7cca16353048a062baeb3a52da55249"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab1b73e05bdb5cc12cdff5a1cf6c4f2a2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gab1b73e05bdb5cc12cdff5a1cf6c4f2a2">LCD_START_LINE4</a>&#160;&#160;&#160;0x54</td></tr>
<tr class="separator:gab1b73e05bdb5cc12cdff5a1cf6c4f2a2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadb35ff6cb242e48ba0545ea919ffc5d3"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gadb35ff6cb242e48ba0545ea919ffc5d3">LCD_WRAP_LINES</a>&#160;&#160;&#160;0</td></tr>
<tr class="separator:gadb35ff6cb242e48ba0545ea919ffc5d3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Definitions for 4-bit IO mode</h2></td></tr>
<tr><td class="ititle" colspan="2"><p><a class="anchor" id="amgrp0d38ed8c5b4202f593f69f9003c1a16c"></a>The four LCD data lines and the three control lines RS, RW, E can be on the same port or on different ports. Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on different ports.</p>
<p>Normally the four data lines should be mapped to bit 0..3 on one port, but it is possible to connect these data lines in different order or even on different ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions.</p>
<p>Adjust these definitions to your target.<br />
These definitions can be defined in a separate include file <b>lcd_definitions.h</b> instead modifying this file by adding <b>-D_LCD_DEFINITIONS_FILE</b> to the <b>CDEFS</b> section in the Makefile. All definitions added to the file lcd_definitions.h will override the default definitions from <a class="el" href="lcd_8h.html">lcd.h</a> </p>
</td></tr>
<tr class="memitem:ga659fcdf979f69bbd14f852f525f25e02"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga659fcdf979f69bbd14f852f525f25e02">LCD_IO_MODE</a>&#160;&#160;&#160;1</td></tr>
<tr class="separator:ga659fcdf979f69bbd14f852f525f25e02"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabcf42bd88b3c36193f301ca25b033875"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a>&#160;&#160;&#160;PORTA</td></tr>
<tr class="separator:gabcf42bd88b3c36193f301ca25b033875"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafc0acd4774bcd311595732f5367e266b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gafc0acd4774bcd311595732f5367e266b">LCD_DATA0_PORT</a>&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td></tr>
<tr class="separator:gafc0acd4774bcd311595732f5367e266b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga345af0248d5739bd8896d4f585618ca2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga345af0248d5739bd8896d4f585618ca2">LCD_DATA1_PORT</a>&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td></tr>
<tr class="separator:ga345af0248d5739bd8896d4f585618ca2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4d5c48a3f2b9426c14bbca3150834a20"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga4d5c48a3f2b9426c14bbca3150834a20">LCD_DATA2_PORT</a>&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td></tr>
<tr class="separator:ga4d5c48a3f2b9426c14bbca3150834a20"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaec71b6692f2af7c9de32dbe85fcb51c2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gaec71b6692f2af7c9de32dbe85fcb51c2">LCD_DATA3_PORT</a>&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td></tr>
<tr class="separator:gaec71b6692f2af7c9de32dbe85fcb51c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafe54d7d886b5c56bed0cf971febbb773"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gafe54d7d886b5c56bed0cf971febbb773">LCD_DATA0_PIN</a>&#160;&#160;&#160;0</td></tr>
<tr class="separator:gafe54d7d886b5c56bed0cf971febbb773"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga97fb520e7b83bb047ac5c9247de57049"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga97fb520e7b83bb047ac5c9247de57049">LCD_DATA1_PIN</a>&#160;&#160;&#160;1</td></tr>
<tr class="separator:ga97fb520e7b83bb047ac5c9247de57049"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7f3d53627337f6535cc8daa35876510a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga7f3d53627337f6535cc8daa35876510a">LCD_DATA2_PIN</a>&#160;&#160;&#160;2</td></tr>
<tr class="separator:ga7f3d53627337f6535cc8daa35876510a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga54032ce0050853e181f879b69fec4370"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga54032ce0050853e181f879b69fec4370">LCD_DATA3_PIN</a>&#160;&#160;&#160;3</td></tr>
<tr class="separator:ga54032ce0050853e181f879b69fec4370"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac5be2a22727fd9ca349e1c9bcbfbcd47"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gac5be2a22727fd9ca349e1c9bcbfbcd47">LCD_RS_PORT</a>&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td></tr>
<tr class="separator:gac5be2a22727fd9ca349e1c9bcbfbcd47"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae5c0a0a5750f3aaea06083e3a4a31f5d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gae5c0a0a5750f3aaea06083e3a4a31f5d">LCD_RS_PIN</a>&#160;&#160;&#160;4</td></tr>
<tr class="separator:gae5c0a0a5750f3aaea06083e3a4a31f5d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae8772bdf31db863b81805c837bdc2da2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gae8772bdf31db863b81805c837bdc2da2">LCD_RW_PORT</a>&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td></tr>
<tr class="separator:gae8772bdf31db863b81805c837bdc2da2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3ac938dd5fc02a9a232df6605b5f6aa8"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga3ac938dd5fc02a9a232df6605b5f6aa8">LCD_RW_PIN</a>&#160;&#160;&#160;5</td></tr>
<tr class="separator:ga3ac938dd5fc02a9a232df6605b5f6aa8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf97f97ff3832d1289bbcb471090ea297"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gaf97f97ff3832d1289bbcb471090ea297">LCD_E_PORT</a>&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td></tr>
<tr class="separator:gaf97f97ff3832d1289bbcb471090ea297"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae644d776392a8d47899d9910c2b8feb6"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gae644d776392a8d47899d9910c2b8feb6">LCD_E_PIN</a>&#160;&#160;&#160;6</td></tr>
<tr class="separator:gae644d776392a8d47899d9910c2b8feb6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Definitions of delays</h2></td></tr>
<tr><td class="ititle" colspan="2"><p><a class="anchor" id="amgrp73324fc181df7d63636f86a5b76e74f2"></a>Used to calculate delay timers. Adapt the F_CPU define in the Makefile to the clock frequency in Hz of your target</p>
<p>These delay times can be adjusted, if some displays require different delays.<br />
These definitions can be defined in a separate include file <b>lcd_definitions.h</b> instead modifying this file by adding <b>-D_LCD_DEFINITIONS_FILE</b> to the <b>CDEFS</b> section in the Makefile. All definitions added to the file lcd_definitions.h will override the default definitions from <a class="el" href="lcd_8h.html">lcd.h</a> </p>
</td></tr>
<tr class="memitem:ga79ca3fe83448ab158a4c566bf292c260"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga79ca3fe83448ab158a4c566bf292c260">LCD_DELAY_BOOTUP</a>&#160;&#160;&#160;16000</td></tr>
<tr class="separator:ga79ca3fe83448ab158a4c566bf292c260"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab6ba3c8cdcf1a96b0d4c476eff8f8617"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gab6ba3c8cdcf1a96b0d4c476eff8f8617">LCD_DELAY_INIT</a>&#160;&#160;&#160;5000</td></tr>
<tr class="separator:gab6ba3c8cdcf1a96b0d4c476eff8f8617"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2ce1ac9b146b7baa7169e27f9cf3a99e"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga2ce1ac9b146b7baa7169e27f9cf3a99e">LCD_DELAY_INIT_REP</a>&#160;&#160;&#160;64</td></tr>
<tr class="separator:ga2ce1ac9b146b7baa7169e27f9cf3a99e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadf773dcbd0827cd15c788065c9197459"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gadf773dcbd0827cd15c788065c9197459">LCD_DELAY_INIT_4BIT</a>&#160;&#160;&#160;64</td></tr>
<tr class="separator:gadf773dcbd0827cd15c788065c9197459"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga73b2370827e2d350cedd45e08a9eb0b2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga73b2370827e2d350cedd45e08a9eb0b2">LCD_DELAY_BUSY_FLAG</a>&#160;&#160;&#160;4</td></tr>
<tr class="separator:ga73b2370827e2d350cedd45e08a9eb0b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5b0632f09757ffe6f018c6ef88cc3296"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga5b0632f09757ffe6f018c6ef88cc3296">LCD_DELAY_ENABLE_PULSE</a>&#160;&#160;&#160;1</td></tr>
<tr class="separator:ga5b0632f09757ffe6f018c6ef88cc3296"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Definitions for LCD command instructions</h2></td></tr>
<tr><td class="ititle" colspan="2"><p><a class="anchor" id="amgrpe1b1604cb195ab970ebf8b6b8b3e322f"></a>The constants define the various LCD controller instructions which can be passed to the function <a class="el" href="group__pfleury__lcd.html#gaea9d14f02df06f948cb5a56776980826" title="Send LCD controller instruction command. ">lcd_command()</a>, see HD44780 data sheet for a complete description. </p>
</td></tr>
<tr class="memitem:ga459688213267d13ccfbeb2c9004988cb"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga459688213267d13ccfbeb2c9004988cb"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_CLR</b>&#160;&#160;&#160;0 /* DB0: clear display */</td></tr>
<tr class="separator:ga459688213267d13ccfbeb2c9004988cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae0e309ccad89222eb3457f2da9f2bb8d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gae0e309ccad89222eb3457f2da9f2bb8d"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_HOME</b>&#160;&#160;&#160;1 /* DB1: return to home position */</td></tr>
<tr class="separator:gae0e309ccad89222eb3457f2da9f2bb8d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae5d757ddb6d94de8c82191b60b40e442"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gae5d757ddb6d94de8c82191b60b40e442"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ENTRY_MODE</b>&#160;&#160;&#160;2 /* DB2: set entry mode */</td></tr>
<tr class="separator:gae5d757ddb6d94de8c82191b60b40e442"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gada766266a0be0d0040fbf86e23b58aa6"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gada766266a0be0d0040fbf86e23b58aa6"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ENTRY_INC</b>&#160;&#160;&#160;1 /* DB1: 1=increment, 0=decrement */</td></tr>
<tr class="separator:gada766266a0be0d0040fbf86e23b58aa6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga14d0c7fda147e0dc8cdaa4a2629b3532"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga14d0c7fda147e0dc8cdaa4a2629b3532"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ENTRY_SHIFT</b>&#160;&#160;&#160;0 /* DB2: 1=display shift on */</td></tr>
<tr class="separator:ga14d0c7fda147e0dc8cdaa4a2629b3532"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga47a809dfec086fdeca93dedc4fb83b44"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga47a809dfec086fdeca93dedc4fb83b44"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ON</b>&#160;&#160;&#160;3 /* DB3: turn lcd/cursor on */</td></tr>
<tr class="separator:ga47a809dfec086fdeca93dedc4fb83b44"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae84f634b0a1661c4d5bbaafd9397732a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gae84f634b0a1661c4d5bbaafd9397732a"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ON_DISPLAY</b>&#160;&#160;&#160;2 /* DB2: turn display on */</td></tr>
<tr class="separator:gae84f634b0a1661c4d5bbaafd9397732a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga47638b5ebbaec9600a0ebf9a55caf802"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga47638b5ebbaec9600a0ebf9a55caf802"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ON_CURSOR</b>&#160;&#160;&#160;1 /* DB1: turn cursor on */</td></tr>
<tr class="separator:ga47638b5ebbaec9600a0ebf9a55caf802"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5d76592a978537acee615098ce4d80f5"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga5d76592a978537acee615098ce4d80f5"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ON_BLINK</b>&#160;&#160;&#160;0 /* DB0: blinking cursor ? */</td></tr>
<tr class="separator:ga5d76592a978537acee615098ce4d80f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3f4f758b80fcfa6c9e4db58e2515c78a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga3f4f758b80fcfa6c9e4db58e2515c78a"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_MOVE</b>&#160;&#160;&#160;4 /* DB4: move cursor/display */</td></tr>
<tr class="separator:ga3f4f758b80fcfa6c9e4db58e2515c78a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaddc2afa9a02bfa748950f2c1e6a204d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaaddc2afa9a02bfa748950f2c1e6a204d"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_MOVE_DISP</b>&#160;&#160;&#160;3 /* DB3: move display (0-&gt; cursor) ? */</td></tr>
<tr class="separator:gaaddc2afa9a02bfa748950f2c1e6a204d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga97cdb19acf109ad52ab4994d2ad02cee"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga97cdb19acf109ad52ab4994d2ad02cee"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_MOVE_RIGHT</b>&#160;&#160;&#160;2 /* DB2: move right (0-&gt; left) ? */</td></tr>
<tr class="separator:ga97cdb19acf109ad52ab4994d2ad02cee"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga50de1697f1da8ab075a6b4d7aeace64e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga50de1697f1da8ab075a6b4d7aeace64e"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_FUNCTION</b>&#160;&#160;&#160;5 /* DB5: function set */</td></tr>
<tr class="separator:ga50de1697f1da8ab075a6b4d7aeace64e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga91d15d8e3008f6cb141406a8b5d0d3c0"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga91d15d8e3008f6cb141406a8b5d0d3c0"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_FUNCTION_8BIT</b>&#160;&#160;&#160;4 /* DB4: set 8BIT mode (0-&gt;4BIT mode) */</td></tr>
<tr class="separator:ga91d15d8e3008f6cb141406a8b5d0d3c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6c24806bed18d565917165caa3475463"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga6c24806bed18d565917165caa3475463"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_FUNCTION_2LINES</b>&#160;&#160;&#160;3 /* DB3: two lines (0-&gt;one line) */</td></tr>
<tr class="separator:ga6c24806bed18d565917165caa3475463"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga48de81358277fe4f2810c2b82f90397e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga48de81358277fe4f2810c2b82f90397e"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_FUNCTION_10DOTS</b>&#160;&#160;&#160;2 /* DB2: 5x10 font (0-&gt;5x7 font) */</td></tr>
<tr class="separator:ga48de81358277fe4f2810c2b82f90397e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3b38de74c362be1781fef1136aa9684c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga3b38de74c362be1781fef1136aa9684c"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_CGRAM</b>&#160;&#160;&#160;6 /* DB6: set CG RAM address */</td></tr>
<tr class="separator:ga3b38de74c362be1781fef1136aa9684c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae54acf3ccc45b7d6be334a03627740c6"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gae54acf3ccc45b7d6be334a03627740c6"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_DDRAM</b>&#160;&#160;&#160;7 /* DB7: set DD RAM address */</td></tr>
<tr class="separator:gae54acf3ccc45b7d6be334a03627740c6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac8dd1658e235f174d1cabae5c438943d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gac8dd1658e235f174d1cabae5c438943d"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_BUSY</b>&#160;&#160;&#160;7 /* DB7: LCD is busy */</td></tr>
<tr class="separator:gac8dd1658e235f174d1cabae5c438943d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaad56f8e07634e85663f56888ae97089c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaad56f8e07634e85663f56888ae97089c"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ENTRY_DEC</b>&#160;&#160;&#160;0x04 /* display shift off, dec cursor move dir */</td></tr>
<tr class="separator:gaad56f8e07634e85663f56888ae97089c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1c62932f252c6262cbef728add9696e4"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga1c62932f252c6262cbef728add9696e4"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ENTRY_DEC_SHIFT</b>&#160;&#160;&#160;0x05 /* display shift on, dec cursor move dir */</td></tr>
<tr class="separator:ga1c62932f252c6262cbef728add9696e4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad27ddc4b8d03594662c8757f946dde28"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gad27ddc4b8d03594662c8757f946dde28"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ENTRY_INC_</b>&#160;&#160;&#160;0x06 /* display shift off, inc cursor move dir */</td></tr>
<tr class="separator:gad27ddc4b8d03594662c8757f946dde28"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafabd0215cc6ae5539dc638dbec44a506"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gafabd0215cc6ae5539dc638dbec44a506"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_ENTRY_INC_SHIFT</b>&#160;&#160;&#160;0x07 /* display shift on, inc cursor move dir */</td></tr>
<tr class="separator:gafabd0215cc6ae5539dc638dbec44a506"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa2966175115943883f51e9c90478540c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaa2966175115943883f51e9c90478540c"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_DISP_OFF</b>&#160;&#160;&#160;0x08 /* display off */</td></tr>
<tr class="separator:gaa2966175115943883f51e9c90478540c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5163a96b133868975c0738e180b30cb8"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga5163a96b133868975c0738e180b30cb8"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_DISP_ON</b>&#160;&#160;&#160;0x0C /* display on, cursor off */</td></tr>
<tr class="separator:ga5163a96b133868975c0738e180b30cb8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga470cef85de53e37356b22c66a357a764"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga470cef85de53e37356b22c66a357a764"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_DISP_ON_BLINK</b>&#160;&#160;&#160;0x0D /* display on, cursor off, blink char */</td></tr>
<tr class="separator:ga470cef85de53e37356b22c66a357a764"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf56b6d6bdb6fa48b26106dee5f74ae1f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaf56b6d6bdb6fa48b26106dee5f74ae1f"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_DISP_ON_CURSOR</b>&#160;&#160;&#160;0x0E /* display on, cursor on */</td></tr>
<tr class="separator:gaf56b6d6bdb6fa48b26106dee5f74ae1f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac1984ed0db15c6991d34c184fdca5dc6"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gac1984ed0db15c6991d34c184fdca5dc6"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_DISP_ON_CURSOR_BLINK</b>&#160;&#160;&#160;0x0F /* display on, cursor on, blink char */</td></tr>
<tr class="separator:gac1984ed0db15c6991d34c184fdca5dc6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac2f0ddce1daaa1bf1a016270a89a264b"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gac2f0ddce1daaa1bf1a016270a89a264b"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_MOVE_CURSOR_LEFT</b>&#160;&#160;&#160;0x10 /* move cursor left (decrement) */</td></tr>
<tr class="separator:gac2f0ddce1daaa1bf1a016270a89a264b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0ad58e39e053e97d34527fcbe936899b"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga0ad58e39e053e97d34527fcbe936899b"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_MOVE_CURSOR_RIGHT</b>&#160;&#160;&#160;0x14 /* move cursor right (increment) */</td></tr>
<tr class="separator:ga0ad58e39e053e97d34527fcbe936899b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab3c34ff1eee238bbe9c677215219fb8e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gab3c34ff1eee238bbe9c677215219fb8e"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_MOVE_DISP_LEFT</b>&#160;&#160;&#160;0x18 /* shift display left */</td></tr>
<tr class="separator:gab3c34ff1eee238bbe9c677215219fb8e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9a90bb926f5ba59378af81fe8e246ffb"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga9a90bb926f5ba59378af81fe8e246ffb"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_MOVE_DISP_RIGHT</b>&#160;&#160;&#160;0x1C /* shift display right */</td></tr>
<tr class="separator:ga9a90bb926f5ba59378af81fe8e246ffb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaff4e5baa36a0322eb97557dcb18cd96e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaff4e5baa36a0322eb97557dcb18cd96e"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_FUNCTION_4BIT_1LINE</b>&#160;&#160;&#160;0x20 /* 4-bit interface, single line, 5x7 dots */</td></tr>
<tr class="separator:gaff4e5baa36a0322eb97557dcb18cd96e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab35032ab368a8bc90798e0c547fb24c2"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gab35032ab368a8bc90798e0c547fb24c2"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_FUNCTION_4BIT_2LINES</b>&#160;&#160;&#160;0x28 /* 4-bit interface, dual line, 5x7 dots */</td></tr>
<tr class="separator:gab35032ab368a8bc90798e0c547fb24c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa8aeee098cb4c84ec420e00d054abcce"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaa8aeee098cb4c84ec420e00d054abcce"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_FUNCTION_8BIT_1LINE</b>&#160;&#160;&#160;0x30 /* 8-bit interface, single line, 5x7 dots */</td></tr>
<tr class="separator:gaa8aeee098cb4c84ec420e00d054abcce"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga160a214f47869f8f98ad5add3a7568db"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga160a214f47869f8f98ad5add3a7568db"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_FUNCTION_8BIT_2LINES</b>&#160;&#160;&#160;0x38 /* 8-bit interface, dual line, 5x7 dots */</td></tr>
<tr class="separator:ga160a214f47869f8f98ad5add3a7568db"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1849e2087d3034a3fffa67444beed109"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga1849e2087d3034a3fffa67444beed109"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>LCD_MODE_DEFAULT</b>&#160;&#160;&#160;((1&lt;&lt;LCD_ENTRY_MODE) | (1&lt;&lt;LCD_ENTRY_INC) )</td></tr>
<tr class="separator:ga1849e2087d3034a3fffa67444beed109"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Functions</h2></td></tr>
<tr class="memitem:ga9af28b2779326b63ff4356e2b1828984"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga9af28b2779326b63ff4356e2b1828984">lcd_init</a> (uint8_t dispAttr)</td></tr>
<tr class="memdesc:ga9af28b2779326b63ff4356e2b1828984"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize display and select type of cursor. <a href="#ga9af28b2779326b63ff4356e2b1828984">More...</a><br /></td></tr>
<tr class="separator:ga9af28b2779326b63ff4356e2b1828984"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf8da853dba4b9d5f2aea4e294444e14d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gaf8da853dba4b9d5f2aea4e294444e14d">lcd_clrscr</a> (void)</td></tr>
<tr class="memdesc:gaf8da853dba4b9d5f2aea4e294444e14d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clear display and set cursor to home position. <a href="#gaf8da853dba4b9d5f2aea4e294444e14d">More...</a><br /></td></tr>
<tr class="separator:gaf8da853dba4b9d5f2aea4e294444e14d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3aabf730aa4e0393bb5c959583c00a8e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga3aabf730aa4e0393bb5c959583c00a8e">lcd_home</a> (void)</td></tr>
<tr class="memdesc:ga3aabf730aa4e0393bb5c959583c00a8e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set cursor to home position. <a href="#ga3aabf730aa4e0393bb5c959583c00a8e">More...</a><br /></td></tr>
<tr class="separator:ga3aabf730aa4e0393bb5c959583c00a8e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadbf47a5efdf02367ded1ebf8f9edb5fe"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gadbf47a5efdf02367ded1ebf8f9edb5fe">lcd_gotoxy</a> (uint8_t x, uint8_t y)</td></tr>
<tr class="memdesc:gadbf47a5efdf02367ded1ebf8f9edb5fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set cursor to specified position. <a href="#gadbf47a5efdf02367ded1ebf8f9edb5fe">More...</a><br /></td></tr>
<tr class="separator:gadbf47a5efdf02367ded1ebf8f9edb5fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafa7e36b95c43d603f510273ad077cbbe"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gafa7e36b95c43d603f510273ad077cbbe">lcd_putc</a> (char c)</td></tr>
<tr class="memdesc:gafa7e36b95c43d603f510273ad077cbbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Display character at current cursor position. <a href="#gafa7e36b95c43d603f510273ad077cbbe">More...</a><br /></td></tr>
<tr class="separator:gafa7e36b95c43d603f510273ad077cbbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8ffdfcac7638368ff04364c14984266e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga8ffdfcac7638368ff04364c14984266e">lcd_puts</a> (const char *s)</td></tr>
<tr class="memdesc:ga8ffdfcac7638368ff04364c14984266e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Display string without auto linefeed. <a href="#ga8ffdfcac7638368ff04364c14984266e">More...</a><br /></td></tr>
<tr class="separator:ga8ffdfcac7638368ff04364c14984266e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9022a24a56a9b15681f62eb6ba77e5de"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga9022a24a56a9b15681f62eb6ba77e5de">lcd_puts_p</a> (const char *progmem_s)</td></tr>
<tr class="memdesc:ga9022a24a56a9b15681f62eb6ba77e5de"><td class="mdescLeft">&#160;</td><td class="mdescRight">Display string from program memory without auto linefeed. <a href="#ga9022a24a56a9b15681f62eb6ba77e5de">More...</a><br /></td></tr>
<tr class="separator:ga9022a24a56a9b15681f62eb6ba77e5de"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaea9d14f02df06f948cb5a56776980826"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gaea9d14f02df06f948cb5a56776980826">lcd_command</a> (uint8_t cmd)</td></tr>
<tr class="memdesc:gaea9d14f02df06f948cb5a56776980826"><td class="mdescLeft">&#160;</td><td class="mdescRight">Send LCD controller instruction command. <a href="#gaea9d14f02df06f948cb5a56776980826">More...</a><br /></td></tr>
<tr class="separator:gaea9d14f02df06f948cb5a56776980826"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad0729d2cba627825a089ca1fff12ba29"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#gad0729d2cba627825a089ca1fff12ba29">lcd_data</a> (uint8_t data)</td></tr>
<tr class="memdesc:gad0729d2cba627825a089ca1fff12ba29"><td class="mdescLeft">&#160;</td><td class="mdescRight">Send data byte to LCD controller. <a href="#gad0729d2cba627825a089ca1fff12ba29">More...</a><br /></td></tr>
<tr class="separator:gad0729d2cba627825a089ca1fff12ba29"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4f1928f1515e21422d5a33af2949f2f7"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga4f1928f1515e21422d5a33af2949f2f7"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__lcd.html#ga4f1928f1515e21422d5a33af2949f2f7">lcd_puts_P</a>(__s)&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#ga9022a24a56a9b15681f62eb6ba77e5de">lcd_puts_p</a>(PSTR(__s))</td></tr>
<tr class="memdesc:ga4f1928f1515e21422d5a33af2949f2f7"><td class="mdescLeft">&#160;</td><td class="mdescRight">macros for automatically storing string constant in program memory <br /></td></tr>
<tr class="separator:ga4f1928f1515e21422d5a33af2949f2f7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ga63574b03f72a197aeee823aae95dc3b7"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_CONTROLLER_KS0073&#160;&#160;&#160;0</td>
</tr>
</table>
</div><div class="memdoc">
<p>Use 0 for HD44780 controller, 1 for KS0073 controller </p>
</div>
</div>
<a class="anchor" id="ga01212e90283511562039db786f65ba98"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_LINES&#160;&#160;&#160;2</td>
</tr>
</table>
</div><div class="memdoc">
<p>number of visible lines of the display </p>
</div>
</div>
<a class="anchor" id="ga684bb4392e384b7ae7c660d81dacb930"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DISP_LENGTH&#160;&#160;&#160;16</td>
</tr>
</table>
</div><div class="memdoc">
<p>visibles characters per line of the display </p>
</div>
</div>
<a class="anchor" id="gae59a728d9dee9f12c817b29d38746ed9"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_LINE_LENGTH&#160;&#160;&#160;0x40</td>
</tr>
</table>
</div><div class="memdoc">
<p>internal line length of the display </p>
</div>
</div>
<a class="anchor" id="gabd056d70a1488ea2eb1aef87e248e234"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_START_LINE1&#160;&#160;&#160;0x00</td>
</tr>
</table>
</div><div class="memdoc">
<p>DDRAM address of first char of line 1 </p>
</div>
</div>
<a class="anchor" id="ga7b317b21058ef031716ba040ef75430a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_START_LINE2&#160;&#160;&#160;0x40</td>
</tr>
</table>
</div><div class="memdoc">
<p>DDRAM address of first char of line 2 </p>
</div>
</div>
<a class="anchor" id="gae7cca16353048a062baeb3a52da55249"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_START_LINE3&#160;&#160;&#160;0x14</td>
</tr>
</table>
</div><div class="memdoc">
<p>DDRAM address of first char of line 3 </p>
</div>
</div>
<a class="anchor" id="gab1b73e05bdb5cc12cdff5a1cf6c4f2a2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_START_LINE4&#160;&#160;&#160;0x54</td>
</tr>
</table>
</div><div class="memdoc">
<p>DDRAM address of first char of line 4 </p>
</div>
</div>
<a class="anchor" id="gadb35ff6cb242e48ba0545ea919ffc5d3"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_WRAP_LINES&#160;&#160;&#160;0</td>
</tr>
</table>
</div><div class="memdoc">
<p>0: no wrap, 1: wrap at end of visibile line </p>
</div>
</div>
<a class="anchor" id="ga659fcdf979f69bbd14f852f525f25e02"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_IO_MODE&#160;&#160;&#160;1</td>
</tr>
</table>
</div><div class="memdoc">
<p>0: memory mapped mode, 1: IO port mode </p>
</div>
</div>
<a class="anchor" id="gabcf42bd88b3c36193f301ca25b033875"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_PORT&#160;&#160;&#160;PORTA</td>
</tr>
</table>
</div><div class="memdoc">
<p>port for the LCD lines </p>
</div>
</div>
<a class="anchor" id="gafc0acd4774bcd311595732f5367e266b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DATA0_PORT&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>port for 4bit data bit 0 </p>
</div>
</div>
<a class="anchor" id="ga345af0248d5739bd8896d4f585618ca2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DATA1_PORT&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>port for 4bit data bit 1 </p>
</div>
</div>
<a class="anchor" id="ga4d5c48a3f2b9426c14bbca3150834a20"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DATA2_PORT&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>port for 4bit data bit 2 </p>
</div>
</div>
<a class="anchor" id="gaec71b6692f2af7c9de32dbe85fcb51c2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DATA3_PORT&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>port for 4bit data bit 3 </p>
</div>
</div>
<a class="anchor" id="gafe54d7d886b5c56bed0cf971febbb773"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DATA0_PIN&#160;&#160;&#160;0</td>
</tr>
</table>
</div><div class="memdoc">
<p>pin for 4bit data bit 0 </p>
</div>
</div>
<a class="anchor" id="ga97fb520e7b83bb047ac5c9247de57049"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DATA1_PIN&#160;&#160;&#160;1</td>
</tr>
</table>
</div><div class="memdoc">
<p>pin for 4bit data bit 1 </p>
</div>
</div>
<a class="anchor" id="ga7f3d53627337f6535cc8daa35876510a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DATA2_PIN&#160;&#160;&#160;2</td>
</tr>
</table>
</div><div class="memdoc">
<p>pin for 4bit data bit 2 </p>
</div>
</div>
<a class="anchor" id="ga54032ce0050853e181f879b69fec4370"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DATA3_PIN&#160;&#160;&#160;3</td>
</tr>
</table>
</div><div class="memdoc">
<p>pin for 4bit data bit 3 </p>
</div>
</div>
<a class="anchor" id="gac5be2a22727fd9ca349e1c9bcbfbcd47"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_RS_PORT&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>port for RS line </p>
</div>
</div>
<a class="anchor" id="gae5c0a0a5750f3aaea06083e3a4a31f5d"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_RS_PIN&#160;&#160;&#160;4</td>
</tr>
</table>
</div><div class="memdoc">
<p>pin for RS line </p>
</div>
</div>
<a class="anchor" id="gae8772bdf31db863b81805c837bdc2da2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_RW_PORT&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>port for RW line </p>
</div>
</div>
<a class="anchor" id="ga3ac938dd5fc02a9a232df6605b5f6aa8"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_RW_PIN&#160;&#160;&#160;5</td>
</tr>
</table>
</div><div class="memdoc">
<p>pin for RW line </p>
</div>
</div>
<a class="anchor" id="gaf97f97ff3832d1289bbcb471090ea297"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_E_PORT&#160;&#160;&#160;<a class="el" href="group__pfleury__lcd.html#gabcf42bd88b3c36193f301ca25b033875">LCD_PORT</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>port for Enable line </p>
</div>
</div>
<a class="anchor" id="gae644d776392a8d47899d9910c2b8feb6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_E_PIN&#160;&#160;&#160;6</td>
</tr>
</table>
</div><div class="memdoc">
<p>pin for Enable line </p>
</div>
</div>
<a class="anchor" id="ga79ca3fe83448ab158a4c566bf292c260"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DELAY_BOOTUP&#160;&#160;&#160;16000</td>
</tr>
</table>
</div><div class="memdoc">
<p>delay in micro seconds after power-on </p>
</div>
</div>
<a class="anchor" id="gab6ba3c8cdcf1a96b0d4c476eff8f8617"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DELAY_INIT&#160;&#160;&#160;5000</td>
</tr>
</table>
</div><div class="memdoc">
<p>delay in micro seconds after initialization command sent </p>
</div>
</div>
<a class="anchor" id="ga2ce1ac9b146b7baa7169e27f9cf3a99e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DELAY_INIT_REP&#160;&#160;&#160;64</td>
</tr>
</table>
</div><div class="memdoc">
<p>delay in micro seconds after initialization command repeated </p>
</div>
</div>
<a class="anchor" id="gadf773dcbd0827cd15c788065c9197459"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DELAY_INIT_4BIT&#160;&#160;&#160;64</td>
</tr>
</table>
</div><div class="memdoc">
<p>delay in micro seconds after setting 4-bit mode </p>
</div>
</div>
<a class="anchor" id="ga73b2370827e2d350cedd45e08a9eb0b2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DELAY_BUSY_FLAG&#160;&#160;&#160;4</td>
</tr>
</table>
</div><div class="memdoc">
<p>time in micro seconds the address counter is updated after busy flag is cleared </p>
</div>
</div>
<a class="anchor" id="ga5b0632f09757ffe6f018c6ef88cc3296"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define LCD_DELAY_ENABLE_PULSE&#160;&#160;&#160;1</td>
</tr>
</table>
</div><div class="memdoc">
<p>enable signal pulse width in micro seconds </p>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga9af28b2779326b63ff4356e2b1828984"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_init </td>
<td>(</td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>dispAttr</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize display and select type of cursor. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dispAttr</td><td><b>LCD_DISP_OFF</b> display off<br />
<b>LCD_DISP_ON</b> display on, cursor off<br />
<b>LCD_DISP_ON_CURSOR</b> display on, cursor on<br />
<b>LCD_DISP_ON_CURSOR_BLINK</b> display on, cursor on flashing </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="gaf8da853dba4b9d5f2aea4e294444e14d"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_clrscr </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Clear display and set cursor to home position. </p>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="ga3aabf730aa4e0393bb5c959583c00a8e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_home </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set cursor to home position. </p>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="gadbf47a5efdf02367ded1ebf8f9edb5fe"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_gotoxy </td>
<td>(</td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>x</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>y</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set cursor to specified position. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">x</td><td>horizontal position<br />
(0: left most position) </td></tr>
<tr><td class="paramname">y</td><td>vertical position<br />
(0: first line) </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="gafa7e36b95c43d603f510273ad077cbbe"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_putc </td>
<td>(</td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>c</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Display character at current cursor position. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">c</td><td>character to be displayed </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="ga8ffdfcac7638368ff04364c14984266e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_puts </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Display string without auto linefeed. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td>string to be displayed </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="ga9022a24a56a9b15681f62eb6ba77e5de"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_puts_p </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>progmem_s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Display string from program memory without auto linefeed. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">progmem_s</td><td>string from program memory be be displayed </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__pfleury__lcd.html#ga4f1928f1515e21422d5a33af2949f2f7" title="macros for automatically storing string constant in program memory ">lcd_puts_P</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaea9d14f02df06f948cb5a56776980826"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_command </td>
<td>(</td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>cmd</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Send LCD controller instruction command. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">cmd</td><td>instruction to send to LCD controller, see HD44780 data sheet </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="gad0729d2cba627825a089ca1fff12ba29"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void lcd_data </td>
<td>(</td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>data</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Send data byte to LCD controller. </p>
<p>Similar to <a class="el" href="group__pfleury__lcd.html#gafa7e36b95c43d603f510273ad077cbbe" title="Display character at current cursor position. ">lcd_putc()</a>, but without interpreting LF </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>byte to send to LCD controller, see HD44780 data sheet </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Jan 31 2015 21:02:51 for AVR-GCC Libraries by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>

167
lab_3/lcdlibrary/test_lcd.c Normal file
View File

@ -0,0 +1,167 @@
/*************************************************************************
Title: Testing output to a HD44780 based LCD display.
Author: Peter Fleury <pfleury@gmx.ch> http://tinyurl.com/peterfleury
File: $Id: test_lcd.c,v 1.8 2015/01/31 18:04:08 peter Exp $
Software: AVR-GCC 4.x
Hardware: HD44780 compatible LCD text display
AVR with external SRAM interface if memory-mapped LCD interface is used
any AVR with 7 free I/O pins if 4-bit IO port mode is used
**************************************************************************/
#include <stdlib.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "lcd.h"
/*
** constant definitions
*/
static const PROGMEM unsigned char copyRightChar[] =
{
0x07, 0x08, 0x13, 0x14, 0x14, 0x13, 0x08, 0x07,
0x00, 0x10, 0x08, 0x08, 0x08, 0x08, 0x10, 0x00
};
/*
** function prototypes
*/
void wait_until_key_pressed(void);
void wait_until_key_pressed(void)
{
unsigned char temp1, temp2;
do {
temp1 = PIND; // read input
_delay_ms(5); // delay for key debounce
temp2 = PIND; // read input
temp1 = (temp1 & temp2); // debounce input
} while ( temp1 & _BV(PIND2) );
loop_until_bit_is_set(PIND,PIND2); /* wait until key is released */
}
int main(void)
{
char buffer[7];
int num=134;
unsigned char i;
DDRD &=~ (1 << PD2); /* Pin PD2 input */
PORTD |= (1 << PD2); /* Pin PD2 pull-up enabled */
/* initialize display, cursor off */
lcd_init(LCD_DISP_ON);
for (;;) { /* loop forever */
/*
* Test 1: write text to display
*/
/* clear display and home cursor */
lcd_clrscr();
/* put string to display (line 1) with linefeed */
lcd_puts("LCD Test Line 1\n");
/* cursor is now on second line, write second line */
lcd_puts("Line 2");
/* move cursor to position 8 on line 2 */
lcd_gotoxy(7,1);
/* write single char to display */
lcd_putc(':');
/* wait until push button PD2 (INT0) is pressed */
wait_until_key_pressed();
/*
* Test 2: use lcd_command() to turn on cursor
*/
/* turn on cursor */
lcd_command(LCD_DISP_ON_CURSOR);
/* put string */
lcd_puts( "CurOn");
/* wait until push button PD2 (INT0) is pressed */
wait_until_key_pressed();
/*
* Test 3: display shift
*/
lcd_clrscr(); /* clear display home cursor */
/* put string from program memory to display */
lcd_puts_P( "Line 1 longer than 14 characters\n" );
lcd_puts_P( "Line 2 longer than 14 characters" );
/* move BOTH lines one position to the left */
lcd_command(LCD_MOVE_DISP_LEFT);
/* wait until push button PD2 (INT0) is pressed */
wait_until_key_pressed();
/* turn off cursor */
lcd_command(LCD_DISP_ON);
/*
* Test: Display integer values
*/
lcd_clrscr(); /* clear display home cursor */
/* convert interger into string */
itoa( num , buffer, 10);
/* put converted string to display */
lcd_puts(buffer);
/* wait until push button PD2 (INT0) is pressed */
wait_until_key_pressed();
/*
* Test: Display userdefined characters
*/
lcd_clrscr(); /* clear display home cursor */
lcd_puts("Copyright: ");
/*
* load two userdefined characters from program memory
* into LCD controller CG RAM location 0 and 1
*/
lcd_command(_BV(LCD_CGRAM)); /* set CG RAM start address 0 */
for(i=0; i<16; i++)
{
lcd_data(pgm_read_byte_near(&copyRightChar[i]));
}
/* move cursor to position 0 on line 2 */
/* Note: this switched back to DD RAM adresses */
lcd_gotoxy(0,1);
/* display user defined (c), built using two user defined chars */
lcd_putc(0);
lcd_putc(1);
/* wait until push button PD2 (INT0) is pressed */
wait_until_key_pressed();
}
}

View File

@ -1,13 +1,72 @@
#include <avr/io.h>
// Set up GPIO here
void pin_setup() {
#include "main.h"
#include "lcdlibrary/lcd.h"
/** @brief Initialises general pins for use.
*
* @note Does not initialise LCD pins. That is handled by lcdlibrary
*/
void pin_init() {
/* Pin Mappings:
* PC0 -> ADC0 input for diode measurement
* PC1 -> ADC1 input for LM35
*/
// Pin Config for Diode ADC
DDRC &= ~(1 << DDRC0);
DIDR0 |= (1 << ADC0D); // Disable digital input
// Pin Config for LM35 ADC
DDRC &= ~(1 << DDRC1);
DIDR0 |= (1 << ADC1D); // Disable digital input
}
/** @brief Initializes ADC with required settings
*/
void adc_init() {
/* ADC Settings
* Use Aref as Vref
* Initially set input as GND
* Data right-adjusted
* No Interrupts
*/
// Set MUX[3:0] to 0b1111 (GND reference)
ADMUX |= (1 << MUX3) | (1 << MUX2) | (1 << MUX1) | (1 << MUX0);
// Make sure data is right adjusted
ADMUX &= ~(1 << ADLAR);
// Set the clock prescaler to 128 (slower ADC means more accurate measurements)
ADCSRA |= (1 << ADPS2) | (1 << ADPS1) (1 << ADPS0);
// Enable ADC
ADCSRA |= (1 << ADEN);
}
/** @brief Blocking function to read an ADC conversion from a selected ADC input.
*
* @note Blocks until conversion finishes, so speed of this function is dependant
* on ADC prescaler.
*/
uint16_t adc_run_conversion(uint8_t adc_selection) {
// Select ADC
ADMUX &= 0xF0 | adc_selection;
// Start conversion
ADCSRA |= (1 << ADSC);
// Wait until conversion is complete
while (ADCSRA & (1 << ADIF));
// Read out conversion value
// may not be correct
return ADC;
}
int main() {
pin_setup()
pin_init();
adc_init();
while (1) {

5
lab_3/main.h Normal file
View File

@ -0,0 +1,5 @@
#ifndef MAIN_H_
#define MAIN_H_
#endif