diff --git a/lab_2/report.fdb_latexmk b/lab_2/report.fdb_latexmk index 2478d44..e016be1 100644 --- a/lab_2/report.fdb_latexmk +++ b/lab_2/report.fdb_latexmk @@ -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" diff --git a/lab_2/report.log b/lab_2/report.log index 6df8991..9d90964 100644 --- a/lab_2/report.log +++ b/lab_2/report.log @@ -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 -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) diff --git a/lab_2/report.pdf b/lab_2/report.pdf index 030c08b..8229bc8 100644 Binary files a/lab_2/report.pdf and b/lab_2/report.pdf differ diff --git a/lab_2/report.synctex.gz b/lab_2/report.synctex.gz index 4eba6e0..f5e0e9c 100644 Binary files a/lab_2/report.synctex.gz and b/lab_2/report.synctex.gz differ diff --git a/lab_2/report.tex b/lab_2/report.tex index e5610bc..905b3e3 100644 --- a/lab_2/report.tex +++ b/lab_2/report.tex @@ -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: diff --git a/lab_3/i2cmaster/i2cmaster.zip b/lab_3/i2cmaster/i2cmaster.zip new file mode 100644 index 0000000..b51c7dd Binary files /dev/null and b/lab_3/i2cmaster/i2cmaster.zip differ diff --git a/lab_3/lcdlibrary/Makefile b/lab_3/lcdlibrary/Makefile new file mode 100644 index 0000000..4001e7c --- /dev/null +++ b/lab_3/lcdlibrary/Makefile @@ -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 +#vpath %.S + + +# 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 + diff --git a/lab_3/lcdlibrary/doxygen.css b/lab_3/lcdlibrary/doxygen.css new file mode 100644 index 0000000..a000833 --- /dev/null +++ b/lab_3/lcdlibrary/doxygen.css @@ -0,0 +1,1449 @@ +/* The standard CSS for doxygen 1.8.9.1 */ + +body, table, div, p, dl { + font: 400 14px/22px Roboto,sans-serif; +} + +/* @group Heading Levels */ + +h1.groupheader { + font-size: 150%; +} + +.title { + font: 400 14px/28px Roboto,sans-serif; + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +h2.groupheader { + border-bottom: 1px solid #879ECB; + color: #354C7B; + font-size: 150%; + font-weight: normal; + margin-top: 1.75em; + padding-top: 8px; + padding-bottom: 4px; + width: 100%; +} + +h3.groupheader { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px cyan; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd { + margin-top: 2px; +} + +p.starttd { + margin-top: 0px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #ffffff; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} + +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 4px 6px; + margin: 4px 8px 4px 2px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} + +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +div.line.glow { + background-color: cyan; + box-shadow: 0 0 10px cyan; +} + + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +div.ah, span.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.classindex ul { + list-style: none; + padding-left: 0; +} + +div.classindex span.ai { + display: inline-block; +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background-color: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; + white-space: nowrap; + vertical-align: top; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.memberdecls td, .fieldtable tr { + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: cyan; + box-shadow: 0 0 15px cyan; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memSeparator { + border-bottom: 1px solid #DEE4F0; + line-height: 1px; + margin: 0px; + padding: 0px; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight { + width: 100%; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; + font-size: 80%; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; + display: table !important; + width: 100%; +} + +.memitem.glow { + box-shadow: 0 0 15px cyan; +} + +.memname { + font-weight: bold; + margin-left: 6px; +} + +.memname td { + vertical-align: bottom; +} + +.memproto, dl.reflist dt { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 4px; + border-top-left-radius: 4px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 4px; + -moz-border-radius-topleft: 4px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 4px; + -webkit-border-top-left-radius: 4px; + +} + +.memdoc, dl.reflist dd { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 10px 2px 10px; + background-color: #FBFCFD; + border-top-width: 0; + background-image:url('nav_g.png'); + background-repeat:repeat-x; + background-color: #FFFFFF; + /* opera specific markup */ + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-bottomright: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} +.paramname code { + line-height: 14px; +} + +.params, .retval, .exception, .tparams { + margin-left: 0px; + padding-left: 0px; +} + +.params .paramname, .retval .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + +table.mlabels { + border-spacing: 0px; +} + +td.mlabels-left { + width: 100%; + padding: 0px; +} + +td.mlabels-right { + vertical-align: bottom; + padding: 0px; + white-space: nowrap; +} + +span.mlabels { + margin-left: 8px; +} + +span.mlabel { + background-color: #728DC1; + border-top:1px solid #5373B4; + border-left:1px solid #5373B4; + border-right:1px solid #C4CFE5; + border-bottom:1px solid #C4CFE5; + text-shadow: none; + color: white; + margin-right: 4px; + padding: 2px 3px; + border-radius: 3px; + font-size: 7pt; + white-space: nowrap; + vertical-align: middle; +} + + + +/* @end */ + +/* these are for tree view inside a (index) page */ + +div.directory { + margin: 10px 0px; + border-top: 1px solid #9CAFD4; + border-bottom: 1px solid #9CAFD4; + width: 100%; +} + +.directory table { + border-collapse:collapse; +} + +.directory td { + margin: 0px; + padding: 0px; + vertical-align: top; +} + +.directory td.entry { + white-space: nowrap; + padding-right: 6px; + padding-top: 3px; +} + +.directory td.entry a { + outline:none; +} + +.directory td.entry a img { + border: none; +} + +.directory td.desc { + width: 100%; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + border-left: 1px solid rgba(0,0,0,0.05); +} + +.directory tr.even { + padding-left: 6px; + background-color: #F7F8FB; +} + +.directory img { + vertical-align: -30%; +} + +.directory .levels { + white-space: nowrap; + width: 100%; + text-align: right; + font-size: 9pt; +} + +.directory .levels span { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + color: #3D578C; +} + +.arrow { + color: #9CAFD4; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; + font-size: 80%; + display: inline-block; + width: 16px; + height: 22px; +} + +.icon { + font-family: Arial, Helvetica; + font-weight: bold; + font-size: 12px; + height: 14px; + width: 16px; + display: inline-block; + background-color: #728DC1; + color: white; + text-align: center; + border-radius: 4px; + margin-left: 2px; + margin-right: 2px; +} + +.icona { + width: 24px; + height: 22px; + display: inline-block; +} + +.iconfopen { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('folderopen.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.iconfclosed { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('folderclosed.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.icondoc { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('doc.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +table.directory { + font: 400 14px Roboto,sans-serif; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +table.fieldtable { + /*width: 100%;*/ + margin-bottom: 10px; + border: 1px solid #A8B8D9; + border-spacing: 0px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid #A8B8D9; + border-bottom: 1px solid #A8B8D9; + vertical-align: top; +} + +.fieldtable td.fieldname { + padding-top: 3px; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid #A8B8D9; + /*width: 100%;*/ +} + +.fieldtable td.fielddoc p:first-child { + margin-top: 0px; +} + +.fieldtable td.fielddoc p:last-child { + margin-bottom: 2px; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + font-size: 90%; + color: #253555; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; + -moz-border-radius-topleft: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid #A8B8D9; +} + + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + background-position: 0 -5px; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; + color: #283A5D; + font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; +} + +.navpath li.navelem a:hover +{ + color:#6884BD; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#364D7C; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.ingroups +{ + font-size: 8pt; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +dl +{ + padding: 0 0 0 10px; +} + +/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug */ +dl.section +{ + margin-left: 0px; + padding-left: 0px; +} + +dl.note +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #00D000; +} + +dl.deprecated +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #505050; +} + +dl.todo +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #00C0E0; +} + +dl.test +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #3030E0; +} + +dl.bug +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 6px; +} + + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectname +{ + font: 300% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font: 120% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #5373B4; +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.diagraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + +div.zoom +{ + border: 1px solid #90A5CE; +} + +dl.citelist { + margin-bottom:50px; +} + +dl.citelist dt { + color:#334975; + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; +} + +dl.citelist dd { + margin:2px 0; + padding:5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: #F4F6FA; + border: 1px solid #D8DFEE; + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 20px 10px 10px; + width: 200px; +} + +div.toc li { + background: url("bdwn.png") no-repeat scroll 0 5px transparent; + font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +div.toc h3 { + font: bold 12px/1.2 Arial,FreeSans,sans-serif; + color: #4665A2; + border-bottom: 0 none; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 30px; +} + +div.toc li.level4 { + margin-left: 45px; +} + +.inherit_header { + font-weight: bold; + color: gray; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.inherit_header td { + padding: 6px 0px 2px 5px; +} + +.inherit { + display: none; +} + +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} + +/* tooltip related style info */ + +.ttc { + position: absolute; + display: none; +} + +#powerTip { + cursor: default; + white-space: nowrap; + background-color: white; + border: 1px solid gray; + border-radius: 4px 4px 4px 4px; + box-shadow: 1px 1px 7px gray; + display: none; + font-size: smaller; + max-width: 80%; + opacity: 0.9; + padding: 1ex 1em 1em; + position: absolute; + z-index: 2147483647; +} + +#powerTip div.ttdoc { + color: grey; + font-style: italic; +} + +#powerTip div.ttname a { + font-weight: bold; +} + +#powerTip div.ttname { + font-weight: bold; +} + +#powerTip div.ttdeci { + color: #006318; +} + +#powerTip div { + margin: 0px; + padding: 0px; + font: 12px/16px Roboto,sans-serif; +} + +#powerTip:before, #powerTip:after { + content: ""; + position: absolute; + margin: 0px; +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.s:after, #powerTip.s:before, +#powerTip.w:after, #powerTip.w:before, +#powerTip.e:after, #powerTip.e:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.nw:after, #powerTip.nw:before, +#powerTip.sw:after, #powerTip.sw:before { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; +} + +#powerTip.n:after, #powerTip.s:after, +#powerTip.w:after, #powerTip.e:after, +#powerTip.nw:after, #powerTip.ne:after, +#powerTip.sw:after, #powerTip.se:after { + border-color: rgba(255, 255, 255, 0); +} + +#powerTip.n:before, #powerTip.s:before, +#powerTip.w:before, #powerTip.e:before, +#powerTip.nw:before, #powerTip.ne:before, +#powerTip.sw:before, #powerTip.se:before { + border-color: rgba(128, 128, 128, 0); +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.nw:after, #powerTip.nw:before { + top: 100%; +} + +#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { + border-top-color: #ffffff; + border-width: 10px; + margin: 0px -10px; +} +#powerTip.n:before { + border-top-color: #808080; + border-width: 11px; + margin: 0px -11px; +} +#powerTip.n:after, #powerTip.n:before { + left: 50%; +} + +#powerTip.nw:after, #powerTip.nw:before { + right: 14px; +} + +#powerTip.ne:after, #powerTip.ne:before { + left: 14px; +} + +#powerTip.s:after, #powerTip.s:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.sw:after, #powerTip.sw:before { + bottom: 100%; +} + +#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { + border-bottom-color: #ffffff; + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { + border-bottom-color: #808080; + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.s:after, #powerTip.s:before { + left: 50%; +} + +#powerTip.sw:after, #powerTip.sw:before { + right: 14px; +} + +#powerTip.se:after, #powerTip.se:before { + left: 14px; +} + +#powerTip.e:after, #powerTip.e:before { + left: 100%; +} +#powerTip.e:after { + border-left-color: #ffffff; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.e:before { + border-left-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +#powerTip.w:after, #powerTip.w:before { + right: 100%; +} +#powerTip.w:after { + border-right-color: #ffffff; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.w:before { + border-right-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +@media print +{ + #top { display: none; } + #side-nav { display: none; } + #nav-path { display: none; } + body { overflow:visible; } + h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } + .summary { display: none; } + .memitem { page-break-inside: avoid; } + #doc-content + { + margin-left:0 !important; + height:auto !important; + width:auto !important; + overflow:inherit; + display:inline; + } +} + diff --git a/lab_3/lcdlibrary/doxygen.png b/lab_3/lcdlibrary/doxygen.png new file mode 100644 index 0000000..3ff17d8 Binary files /dev/null and b/lab_3/lcdlibrary/doxygen.png differ diff --git a/lab_3/lcdlibrary/lcd.c b/lab_3/lcdlibrary/lcd.c new file mode 100644 index 0000000..8d7eb9c --- /dev/null +++ b/lab_3/lcdlibrary/lcd.c @@ -0,0 +1,592 @@ +/**************************************************************************** + Title: HD44780U LCD library + Author: Peter Fleury 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 +#include +#include +#include +#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 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_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<>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 */ diff --git a/lab_3/lcdlibrary/lcd.h b/lab_3/lcdlibrary/lcd.h new file mode 100644 index 0000000..e4df094 --- /dev/null +++ b/lab_3/lcdlibrary/lcd.h @@ -0,0 +1,369 @@ +#ifndef LCD_H +#define LCD_H +/************************************************************************* + Title : C include file for the HD44780U LCD library (lcd.c) + Author: Peter Fleury 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 + @code #include @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 Interfacing a HD44780 Based LCD to an AVR + 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 +#include + +#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< + + + + + +AVR-GCC Libraries: LCD library <lcd.h> + + + + + + +
+
+ + + + + + +
+
AVR-GCC Libraries +
+
+
+ + + +
+
+
+
LCD library <lcd.h>
+
+
+

Detailed Description

+

Basic routines for interfacing a HD44780U-based character LCD display.

+
#include <lcd.h>
+

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 also
The chapter Interfacing a HD44780 Based LCD to an AVR on my home page, which shows example circuits how to connect an LCD to an AVR controller.
+
Author
Peter Fleury pfleu.nosp@m.ry@g.nosp@m.mx.ch http://tinyurl.com/peterfleury
+
Version
2.0
+ + + + + + +

+Definition for LCD controller type

Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller.

+
#define LCD_CONTROLLER_KS0073   0
 
+ + + + + + + + + + + + + + + + + + +

+Definitions for Display Size

Change these definitions to adapt setting to your display

+

These definitions can be defined in a separate include file 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

+
#define LCD_LINES   2
 
#define LCD_DISP_LENGTH   16
 
#define LCD_LINE_LENGTH   0x40
 
#define LCD_START_LINE1   0x00
 
#define LCD_START_LINE2   0x40
 
#define LCD_START_LINE3   0x14
 
#define LCD_START_LINE4   0x54
 
#define LCD_WRAP_LINES   0
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+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.
+ These definitions can be defined in a separate include file 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

+
#define LCD_IO_MODE   1
 
#define LCD_PORT   PORTA
 
#define LCD_DATA0_PORT   LCD_PORT
 
#define LCD_DATA1_PORT   LCD_PORT
 
#define LCD_DATA2_PORT   LCD_PORT
 
#define LCD_DATA3_PORT   LCD_PORT
 
#define LCD_DATA0_PIN   0
 
#define LCD_DATA1_PIN   1
 
#define LCD_DATA2_PIN   2
 
#define LCD_DATA3_PIN   3
 
#define LCD_RS_PORT   LCD_PORT
 
#define LCD_RS_PIN   4
 
#define LCD_RW_PORT   LCD_PORT
 
#define LCD_RW_PIN   5
 
#define LCD_E_PORT   LCD_PORT
 
#define LCD_E_PIN   6
 
+ + + + + + + + + + + + + + +

+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.
+ These definitions can be defined in a separate include file 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

+
#define LCD_DELAY_BOOTUP   16000
 
#define LCD_DELAY_INIT   5000
 
#define LCD_DELAY_INIT_REP   64
 
#define LCD_DELAY_INIT_4BIT   64
 
#define LCD_DELAY_BUSY_FLAG   4
 
#define LCD_DELAY_ENABLE_PULSE   1
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+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.

+
+#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 */
 
+#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 */
 
+#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 */
 
+#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 */
 
+#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) )
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Functions

void lcd_init (uint8_t dispAttr)
 Initialize display and select type of cursor. More...
 
void lcd_clrscr (void)
 Clear display and set cursor to home position. More...
 
void lcd_home (void)
 Set cursor to home position. More...
 
void lcd_gotoxy (uint8_t x, uint8_t y)
 Set cursor to specified position. More...
 
void lcd_putc (char c)
 Display character at current cursor position. More...
 
void lcd_puts (const char *s)
 Display string without auto linefeed. More...
 
void lcd_puts_p (const char *progmem_s)
 Display string from program memory without auto linefeed. More...
 
void lcd_command (uint8_t cmd)
 Send LCD controller instruction command. More...
 
void lcd_data (uint8_t data)
 Send data byte to LCD controller. More...
 
+#define lcd_puts_P(__s)   lcd_puts_p(PSTR(__s))
 macros for automatically storing string constant in program memory
 
+

Macro Definition Documentation

+ +
+
+ + + + +
#define LCD_CONTROLLER_KS0073   0
+
+

Use 0 for HD44780 controller, 1 for KS0073 controller

+ +
+
+ +
+
+ + + + +
#define LCD_LINES   2
+
+

number of visible lines of the display

+ +
+
+ +
+
+ + + + +
#define LCD_DISP_LENGTH   16
+
+

visibles characters per line of the display

+ +
+
+ +
+
+ + + + +
#define LCD_LINE_LENGTH   0x40
+
+

internal line length of the display

+ +
+
+ +
+
+ + + + +
#define LCD_START_LINE1   0x00
+
+

DDRAM address of first char of line 1

+ +
+
+ +
+
+ + + + +
#define LCD_START_LINE2   0x40
+
+

DDRAM address of first char of line 2

+ +
+
+ +
+
+ + + + +
#define LCD_START_LINE3   0x14
+
+

DDRAM address of first char of line 3

+ +
+
+ +
+
+ + + + +
#define LCD_START_LINE4   0x54
+
+

DDRAM address of first char of line 4

+ +
+
+ +
+
+ + + + +
#define LCD_WRAP_LINES   0
+
+

0: no wrap, 1: wrap at end of visibile line

+ +
+
+ +
+
+ + + + +
#define LCD_IO_MODE   1
+
+

0: memory mapped mode, 1: IO port mode

+ +
+
+ +
+
+ + + + +
#define LCD_PORT   PORTA
+
+

port for the LCD lines

+ +
+
+ +
+
+ + + + +
#define LCD_DATA0_PORT   LCD_PORT
+
+

port for 4bit data bit 0

+ +
+
+ +
+
+ + + + +
#define LCD_DATA1_PORT   LCD_PORT
+
+

port for 4bit data bit 1

+ +
+
+ +
+
+ + + + +
#define LCD_DATA2_PORT   LCD_PORT
+
+

port for 4bit data bit 2

+ +
+
+ +
+
+ + + + +
#define LCD_DATA3_PORT   LCD_PORT
+
+

port for 4bit data bit 3

+ +
+
+ +
+
+ + + + +
#define LCD_DATA0_PIN   0
+
+

pin for 4bit data bit 0

+ +
+
+ +
+
+ + + + +
#define LCD_DATA1_PIN   1
+
+

pin for 4bit data bit 1

+ +
+
+ +
+
+ + + + +
#define LCD_DATA2_PIN   2
+
+

pin for 4bit data bit 2

+ +
+
+ +
+
+ + + + +
#define LCD_DATA3_PIN   3
+
+

pin for 4bit data bit 3

+ +
+
+ +
+
+ + + + +
#define LCD_RS_PORT   LCD_PORT
+
+

port for RS line

+ +
+
+ +
+
+ + + + +
#define LCD_RS_PIN   4
+
+

pin for RS line

+ +
+
+ +
+
+ + + + +
#define LCD_RW_PORT   LCD_PORT
+
+

port for RW line

+ +
+
+ +
+
+ + + + +
#define LCD_RW_PIN   5
+
+

pin for RW line

+ +
+
+ +
+
+ + + + +
#define LCD_E_PORT   LCD_PORT
+
+

port for Enable line

+ +
+
+ +
+
+ + + + +
#define LCD_E_PIN   6
+
+

pin for Enable line

+ +
+
+ +
+
+ + + + +
#define LCD_DELAY_BOOTUP   16000
+
+

delay in micro seconds after power-on

+ +
+
+ +
+
+ + + + +
#define LCD_DELAY_INIT   5000
+
+

delay in micro seconds after initialization command sent

+ +
+
+ +
+
+ + + + +
#define LCD_DELAY_INIT_REP   64
+
+

delay in micro seconds after initialization command repeated

+ +
+
+ +
+
+ + + + +
#define LCD_DELAY_INIT_4BIT   64
+
+

delay in micro seconds after setting 4-bit mode

+ +
+
+ +
+
+ + + + +
#define LCD_DELAY_BUSY_FLAG   4
+
+

time in micro seconds the address counter is updated after busy flag is cleared

+ +
+
+ +
+
+ + + + +
#define LCD_DELAY_ENABLE_PULSE   1
+
+

enable signal pulse width in micro seconds

+ +
+
+

Function Documentation

+ +
+
+ + + + + + + + +
void lcd_init (uint8_t dispAttr)
+
+ +

Initialize display and select type of cursor.

+
Parameters
+ + +
dispAttrLCD_DISP_OFF display off
+ LCD_DISP_ON display on, cursor off
+ LCD_DISP_ON_CURSOR display on, cursor on
+ LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing
+
+
+
Returns
none
+ +
+
+ +
+
+ + + + + + + + +
void lcd_clrscr (void )
+
+ +

Clear display and set cursor to home position.

+
Returns
none
+ +
+
+ +
+
+ + + + + + + + +
void lcd_home (void )
+
+ +

Set cursor to home position.

+
Returns
none
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
void lcd_gotoxy (uint8_t x,
uint8_t y 
)
+
+ +

Set cursor to specified position.

+
Parameters
+ + + +
xhorizontal position
+ (0: left most position)
yvertical position
+ (0: first line)
+
+
+
Returns
none
+ +
+
+ +
+
+ + + + + + + + +
void lcd_putc (char c)
+
+ +

Display character at current cursor position.

+
Parameters
+ + +
ccharacter to be displayed
+
+
+
Returns
none
+ +
+
+ +
+
+ + + + + + + + +
void lcd_puts (const char * s)
+
+ +

Display string without auto linefeed.

+
Parameters
+ + +
sstring to be displayed
+
+
+
Returns
none
+ +
+
+ +
+
+ + + + + + + + +
void lcd_puts_p (const char * progmem_s)
+
+ +

Display string from program memory without auto linefeed.

+
Parameters
+ + +
progmem_sstring from program memory be be displayed
+
+
+
Returns
none
+
See also
lcd_puts_P
+ +
+
+ +
+
+ + + + + + + + +
void lcd_command (uint8_t cmd)
+
+ +

Send LCD controller instruction command.

+
Parameters
+ + +
cmdinstruction to send to LCD controller, see HD44780 data sheet
+
+
+
Returns
none
+ +
+
+ +
+
+ + + + + + + + +
void lcd_data (uint8_t data)
+
+ +

Send data byte to LCD controller.

+

Similar to lcd_putc(), but without interpreting LF

Parameters
+ + +
databyte to send to LCD controller, see HD44780 data sheet
+
+
+
Returns
none
+ +
+
+
+ + + + diff --git a/lab_3/lcdlibrary/test_lcd.c b/lab_3/lcdlibrary/test_lcd.c new file mode 100644 index 0000000..2ddcb6b --- /dev/null +++ b/lab_3/lcdlibrary/test_lcd.c @@ -0,0 +1,167 @@ +/************************************************************************* +Title: Testing output to a HD44780 based LCD display. +Author: Peter Fleury 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 +#include +#include +#include +#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(©RightChar[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(); + + } +} diff --git a/lab_3/main.c b/lab_3/main.c index fb3e1e6..af7c537 100755 --- a/lab_3/main.c +++ b/lab_3/main.c @@ -1,13 +1,72 @@ #include -// 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) { diff --git a/lab_3/main.h b/lab_3/main.h new file mode 100644 index 0000000..5655cab --- /dev/null +++ b/lab_3/main.h @@ -0,0 +1,5 @@ +#ifndef MAIN_H_ +#define MAIN_H_ + + +#endif \ No newline at end of file