From 3f14db0941914ba9b38bad37b2a124c27a6cc27d Mon Sep 17 00:00:00 2001 From: Jan-Philipp Warmers Date: Sun, 9 Mar 2014 11:03:06 +0100 Subject: [PATCH] added servo version initial --- display_v2/software/.idea/.name | 1 + display_v2/software/.idea/compiler.xml | 23 + .../.idea/copyright/profiles_settings.xml | 5 + display_v2/software/.idea/encodings.xml | 5 + display_v2/software/.idea/misc.xml | 13 + display_v2/software/.idea/modules.xml | 11 + .../software/.idea/scopes/scope_settings.xml | 5 + display_v2/software/.idea/uiDesigner.xml | 125 +++ display_v2/software/.idea/vcs.xml | 7 + display_v2/software/.idea/workspace.xml | 651 +++++++++++++ display_v2/software/atlassian-ide-plugin.xml | 6 + display_v2/software/displayboard/Makefile | 276 ++++++ .../software/displayboard/displayboard.iml | 12 + .../software/displayboard/src/.main.c.swp | Bin 0 -> 20480 bytes display_v2/software/displayboard/src/main.c | 254 +++++ display_v2/software/displayboard/src/main.h | 29 + display_v2/software/displayboard/src/uart.c | 479 +++++++++ display_v2/software/displayboard/src/uart.h | 180 ++++ display_v2/software/displayboard/src/utils.c | 39 + display_v2/software/displayboard/src/utils.h | 12 + display_v2/software/powerboard/Makefile | 276 ++++++ display_v2/software/powerboard/powerboard.iml | 12 + display_v2/software/powerboard/src/adc.c | 42 + display_v2/software/powerboard/src/adc.h | 8 + display_v2/software/powerboard/src/main.c | 232 +++++ display_v2/software/powerboard/src/main.h | 41 + display_v2/software/powerboard/src/uart.c | 663 +++++++++++++ display_v2/software/powerboard/src/uart.h | 180 ++++ display_v2/software/powerboard/src/utils.c | 36 + display_v2/software/powerboard/src/utils.h | 12 + .../software/powerboard_v2/.dep/adc.o.d | 33 + .../software/powerboard_v2/.dep/main.o.d | 52 + .../software/powerboard_v2/.dep/uart.o.d | 45 + .../software/powerboard_v2/.dep/utils.o.d | 45 + display_v2/software/powerboard_v2/Makefile | 276 ++++++ display_v2/software/powerboard_v2/main.eep | 1 + display_v2/software/powerboard_v2/main.elf | Bin 0 -> 7652 bytes display_v2/software/powerboard_v2/main.hex | 117 +++ display_v2/software/powerboard_v2/main.lss | 913 ++++++++++++++++++ display_v2/software/powerboard_v2/main.map | 543 +++++++++++ display_v2/software/powerboard_v2/main.sym | 119 +++ .../software/powerboard_v2/powerboard_v2.iml | 12 + display_v2/software/powerboard_v2/src/adc.c | 42 + display_v2/software/powerboard_v2/src/adc.h | 8 + display_v2/software/powerboard_v2/src/adc.lst | 100 ++ display_v2/software/powerboard_v2/src/adc.o | Bin 0 -> 1064 bytes display_v2/software/powerboard_v2/src/main.c | 204 ++++ display_v2/software/powerboard_v2/src/main.h | 38 + .../software/powerboard_v2/src/main.lst | 544 +++++++++++ display_v2/software/powerboard_v2/src/main.o | Bin 0 -> 4756 bytes display_v2/software/powerboard_v2/src/uart.c | 663 +++++++++++++ display_v2/software/powerboard_v2/src/uart.h | 180 ++++ .../software/powerboard_v2/src/uart.lst | 256 +++++ display_v2/software/powerboard_v2/src/uart.o | Bin 0 -> 2008 bytes display_v2/software/powerboard_v2/src/utils.c | 36 + display_v2/software/powerboard_v2/src/utils.h | 12 + .../software/powerboard_v2/src/utils.lst | 191 ++++ display_v2/software/powerboard_v2/src/utils.o | Bin 0 -> 1568 bytes 58 files changed, 8065 insertions(+) create mode 100644 display_v2/software/.idea/.name create mode 100644 display_v2/software/.idea/compiler.xml create mode 100644 display_v2/software/.idea/copyright/profiles_settings.xml create mode 100644 display_v2/software/.idea/encodings.xml create mode 100644 display_v2/software/.idea/misc.xml create mode 100644 display_v2/software/.idea/modules.xml create mode 100644 display_v2/software/.idea/scopes/scope_settings.xml create mode 100644 display_v2/software/.idea/uiDesigner.xml create mode 100644 display_v2/software/.idea/vcs.xml create mode 100644 display_v2/software/.idea/workspace.xml create mode 100644 display_v2/software/atlassian-ide-plugin.xml create mode 100644 display_v2/software/displayboard/Makefile create mode 100644 display_v2/software/displayboard/displayboard.iml create mode 100644 display_v2/software/displayboard/src/.main.c.swp create mode 100644 display_v2/software/displayboard/src/main.c create mode 100644 display_v2/software/displayboard/src/main.h create mode 100644 display_v2/software/displayboard/src/uart.c create mode 100644 display_v2/software/displayboard/src/uart.h create mode 100644 display_v2/software/displayboard/src/utils.c create mode 100644 display_v2/software/displayboard/src/utils.h create mode 100644 display_v2/software/powerboard/Makefile create mode 100644 display_v2/software/powerboard/powerboard.iml create mode 100644 display_v2/software/powerboard/src/adc.c create mode 100644 display_v2/software/powerboard/src/adc.h create mode 100644 display_v2/software/powerboard/src/main.c create mode 100644 display_v2/software/powerboard/src/main.h create mode 100644 display_v2/software/powerboard/src/uart.c create mode 100644 display_v2/software/powerboard/src/uart.h create mode 100644 display_v2/software/powerboard/src/utils.c create mode 100644 display_v2/software/powerboard/src/utils.h create mode 100644 display_v2/software/powerboard_v2/.dep/adc.o.d create mode 100644 display_v2/software/powerboard_v2/.dep/main.o.d create mode 100644 display_v2/software/powerboard_v2/.dep/uart.o.d create mode 100644 display_v2/software/powerboard_v2/.dep/utils.o.d create mode 100644 display_v2/software/powerboard_v2/Makefile create mode 100644 display_v2/software/powerboard_v2/main.eep create mode 100755 display_v2/software/powerboard_v2/main.elf create mode 100644 display_v2/software/powerboard_v2/main.hex create mode 100644 display_v2/software/powerboard_v2/main.lss create mode 100644 display_v2/software/powerboard_v2/main.map create mode 100644 display_v2/software/powerboard_v2/main.sym create mode 100644 display_v2/software/powerboard_v2/powerboard_v2.iml create mode 100644 display_v2/software/powerboard_v2/src/adc.c create mode 100644 display_v2/software/powerboard_v2/src/adc.h create mode 100644 display_v2/software/powerboard_v2/src/adc.lst create mode 100644 display_v2/software/powerboard_v2/src/adc.o create mode 100644 display_v2/software/powerboard_v2/src/main.c create mode 100644 display_v2/software/powerboard_v2/src/main.h create mode 100644 display_v2/software/powerboard_v2/src/main.lst create mode 100644 display_v2/software/powerboard_v2/src/main.o create mode 100644 display_v2/software/powerboard_v2/src/uart.c create mode 100644 display_v2/software/powerboard_v2/src/uart.h create mode 100644 display_v2/software/powerboard_v2/src/uart.lst create mode 100644 display_v2/software/powerboard_v2/src/uart.o create mode 100644 display_v2/software/powerboard_v2/src/utils.c create mode 100644 display_v2/software/powerboard_v2/src/utils.h create mode 100644 display_v2/software/powerboard_v2/src/utils.lst create mode 100644 display_v2/software/powerboard_v2/src/utils.o diff --git a/display_v2/software/.idea/.name b/display_v2/software/.idea/.name new file mode 100644 index 0000000..102e082 --- /dev/null +++ b/display_v2/software/.idea/.name @@ -0,0 +1 @@ +bikegenerator \ No newline at end of file diff --git a/display_v2/software/.idea/compiler.xml b/display_v2/software/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/display_v2/software/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/display_v2/software/.idea/copyright/profiles_settings.xml b/display_v2/software/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..3572571 --- /dev/null +++ b/display_v2/software/.idea/copyright/profiles_settings.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/display_v2/software/.idea/encodings.xml b/display_v2/software/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/display_v2/software/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/display_v2/software/.idea/misc.xml b/display_v2/software/.idea/misc.xml new file mode 100644 index 0000000..1c7f307 --- /dev/null +++ b/display_v2/software/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/display_v2/software/.idea/modules.xml b/display_v2/software/.idea/modules.xml new file mode 100644 index 0000000..4947bdb --- /dev/null +++ b/display_v2/software/.idea/modules.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/display_v2/software/.idea/scopes/scope_settings.xml b/display_v2/software/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/display_v2/software/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/display_v2/software/.idea/uiDesigner.xml b/display_v2/software/.idea/uiDesigner.xml new file mode 100644 index 0000000..3b00020 --- /dev/null +++ b/display_v2/software/.idea/uiDesigner.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/display_v2/software/.idea/vcs.xml b/display_v2/software/.idea/vcs.xml new file mode 100644 index 0000000..9ab281a --- /dev/null +++ b/display_v2/software/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/display_v2/software/.idea/workspace.xml b/display_v2/software/.idea/workspace.xml new file mode 100644 index 0000000..bedf6d2 --- /dev/null +++ b/display_v2/software/.idea/workspace.xml @@ -0,0 +1,651 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CDI(Contexts and Dependency Injection) issues + + + GeneralJavaScript + + + JavaScript + + + Spring Model + + + Spring SecuritySpring Model + + + + + Abstraction issues + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + 1370952913198 + 1370952913198 + + + 1370989849092 + 1370989849092 + + + 1370994654693 + 1370994654693 + + + 1371043815539 + 1371043815539 + + + 1371043908804 + 1371043908804 + + + 1371075233272 + 1371075233272 + + + 1371166480748 + 1371166480748 + + + 1371166541841 + 1371166541841 + + + 1371166559819 + 1371166559819 + + + 1371206855146 + 1371206855146 + + + 1371214968413 + 1371214968413 + + + 1371215016953 + 1371215016953 + + + 1371215050508 + 1371215050508 + + + 1371242761894 + 1371242761894 + + + 1371244728060 + 1371244728060 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Detection + + + + + + + + Node.js v0.8.17 Core Modules + + + + + + + + Cpp SDK + + + + + + + + displayboard + + + + + + + + + + + + + + + + diff --git a/display_v2/software/atlassian-ide-plugin.xml b/display_v2/software/atlassian-ide-plugin.xml new file mode 100644 index 0000000..31cdb22 --- /dev/null +++ b/display_v2/software/atlassian-ide-plugin.xml @@ -0,0 +1,6 @@ + + + + a36e3af5-abd2-4783-a6a6-3383b8cb560f + + \ No newline at end of file diff --git a/display_v2/software/displayboard/Makefile b/display_v2/software/displayboard/Makefile new file mode 100644 index 0000000..bbb562c --- /dev/null +++ b/display_v2/software/displayboard/Makefile @@ -0,0 +1,276 @@ +# On command line: +# +# make all = Make 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! +# +# To rebuild project do "make clean" then "make all". +# + +MCU = atmega32 +F_CPU = 8000000 + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + +# Target file name (without extension). +TARGET = main + +SRC = src/$(TARGET).c src/utils.c src/uart.c + + +# 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 + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +EXTRAINCDIRS = src/ + + +# Compiler flag to set the C Standard level. +# c89 - "ANSI" C +# gnu89 - c89 plus GCC extensions +# c99 - ISO C99 standard (not yet fully implemented) +# gnu99 - c99 plus GCC extensions +CSTANDARD = -std=gnu99 + +# Place -D or -U options here +CDEFS = + +# Place -I options here +CINCS = + + +# Compiler flags. +# -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 += $(CDEFS) $(CINCS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +CFLAGS += -Wall -Wstrict-prototypes +CFLAGS += -Wa,-adhlns=$(<:.c=.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) +CFLAGS += -DF_CPU=$(F_CPU) #-DDEBUG + + + +# External memory options + + +# Linker flags. +# -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 + + +# Programming support using avrdude. Settings and variables. +AVRDUDE_PROGRAMMER = usbasp +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + +AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) + + +# --------------------------------------------------------------------------- + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +COPY = cp + + + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +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 = $(ASRC:.S=.lst) $(SRC:.c=.lst) + + +# Compiler flags to generate dependency files. +### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d +GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) + + +# Default target. +all: begin gccversion sizebefore build sizeafter finished end + +build: elf hex eep lss sym + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +finished: + @echo $(MSG_ERRORS_NONE) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) -A $(TARGET).elf +sizebefore: + @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi + +sizeafter: + @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +%.eep: %.elf + @echo + @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 + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + +# Target: clean project. +clean: begin clean_list finished end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).a90 + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lnk + $(REMOVE) $(TARGET).lss + $(REMOVE) $(OBJ) + $(REMOVE) $(LST) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) .dep/* + + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff \ +clean clean_list program + diff --git a/display_v2/software/displayboard/displayboard.iml b/display_v2/software/displayboard/displayboard.iml new file mode 100644 index 0000000..7694e87 --- /dev/null +++ b/display_v2/software/displayboard/displayboard.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/display_v2/software/displayboard/src/.main.c.swp b/display_v2/software/displayboard/src/.main.c.swp new file mode 100644 index 0000000000000000000000000000000000000000..9dfaf30fdf57e086e7628e1ac4055f0986f7d15b GIT binary patch literal 20480 zcmeI4d5k1g9mfln1)9r)LsnLOJFILs(=%N)N6!p1yV7&)GI1{FSb<^aR99Db*GzR) zr>c5pm)*e_j&P~b7*Qk}0g1$bA!>*cz&}uqh!HeK4#htdP%bqX5d(|g->a(b>YnbM z9gO;iRhv&&z3cbh`_+5Ds(Qb-lM(lhjv@jZk@UJ*wcjNML{T8W?nAp zszqr>I2O%n+=^vc)Q^Rwp zflvdX20{&l8VEHIY9Q1=sDV%e{|6dyN}Ghwpr6NjeZAN_A5(We&I^CZJKtQFzR3%p z=A9)^fG@|34o{&5LJfo(2sIFDAk;vpflvdX20{&l8VEHIY9Q3W|3CwBRuFF9EC{Ec zfXd6a0uKA_JX%h6oh-h zcfdX1^I!p71U7?B;34RB74(3!z?pz_-32}jwg3S<3LXSs05X^YlVAWOz)Q!Ye((qI zJoqX2GFSzRpc9+}HiP59KXFgr0zU&!fFFW8!R259%!4^F20jMP28Xf8^D6iexDVV4 zt_0Iy1e^^%0N%u6&r9Hb@ICM~a1e}xBp+tuvKkR0k$r3@ z>uKB9?_IKJSu-3dnRa4P7L95KYhz~FiLnH8)M6>d&S$;tVhq{qORtR~(Ls6Z0ebr~K54(CN<^0>yn~PrCt|RAdo?1z%TpZ1yS(|xn zj6X)al;#=McE+h>b}s~&h{ofj*??F(rkSeSDr+RBLEMI_3uF#l2B%(w8u$ci7QfC! zZBVR16xGlqdOfW*DCS0?e+|-HW3VbP9AhKH>8Z)-S;UF`s{)TpBv?^iQdw4ZWL7dQ z$7YU6wx?8fkYRRoeCCr31)|cxz~s>Ah?I);ldPHpLT0t1YPAiS#S%8Nu~EZOEvsB| zm~04;GBh+T4SG^Oy=PqNh_QoQ;ze z$E6gEVNDY#K+Q1od0jPFM%9?#m~q)r3Ic-|>b&2KsX@ta#MEGoG>Dlh>w3Awat}XX zF{HAxk;Peph~eRBk|1Uzeu!c}B6-zZjf$z4iw4YgR?BM+%Uaqpx=_-LpjvH5b~J@8 zn_AXYd0I0xCraTMJAkJh7fE8*JJ8gY$8mJkTGBL?CHc zw%LqoEt|HMH)NfyXjYcVWt(N8j$tjAQ!UlF0xB?s1H$Ocbd*Ng$h4Hk&7Df6msQ1K zvHEsHZe?I)RP4sg>SZHuTNtgHp$bUmqmYp{5n2_{5?j@xv3_cjYRDN~MWQz}ZA$jW zH@c7>+zZ{g1DsOauF=p(=lEEI40Q9ND|k6~L?3j^RfaSP;X@k3+q)KHte-|EhBl+2 z&2pyYwNt_rNDgXv%&%xpft9==&&(W4c2O-%(M@HEX*TN}N4@AxVB|P7cYOBa>8aI!AkSr?XgSX%YVyYf5h!pXX@QX7_f zYr~ylZ8%9`8Wq$fkyoKmlwumT!^krCrX7~i@)_AmJC{@cTUbGf=|?4qpewH5W%R+5BR=&cWR^z_ARl(TM1T>>^S2TG8-5o53LI5LB?lf#o2xQ~>K=HxV0&vMz6 zlZ5(NkDN1GE|!j*6Ze{4mzh$wU`d=bY=GOY`UJd7^Bz|Ev25y&4C}^YF~^o=y{y{I zR$=2!veso8b~I<1MOPPmN4BdV-U&79+V+Z6iVZ|TKFm8TjXxfBuSBLyW^cZW-%19v zO8*!Jh;X_5u3-p9DL=dEgyn{tb8*JOfC^uR(Z(8VEHIY9Q1=sDV%ep$0+? zgc=An5NaUQK&XNLo(3u_`@^Gq{Kb7*dGr?@;4`Fe{lL<{pW>}A_(3co@tiXwdq*Z_ zM)uUn<4Y2)h$Js0N%Zsil?K-=__Z%k%T*e~c6G*>U!l89L8APa)>cYeG+rI`L0uO?_z_s8SFb8JA$H5ukbns{R@?QtP0^bF<027ek ze*l~Y-hdDPIdC`lBG?bcfCRRHSKzCE68r#M1uh3epcVWbzWJxXec%vS1iL{i_z2hv z1n>+TaX$x-gGa$5;2v-zxE@>w@?bX@0q1~s;k!Q!o&a}%+rd@90vCe`Kz{z+pbeY_ zP6iQhA~*rO2*3Rc;K$%Apa2%YrQj0K2TlRUfWz?FzXN^??ge*(+re$%vmgyF1bv_l zoDBX7pZ&|=dGH)~7TgaGfv|B)B-PnADG90)LlE_Q-G5RzKsaw zpuahiCb4jPA!?<7rRXSJos^zci)PxhjXYVP5=FIWt4`E&8NmAyXWrVcXX<$)xr=fx zH9eaiOwA3aXGX?GhGwHuUkCg!yVFBcb1~$O1e{V7Zmng{$+sdPS1>{NXMb|2>9cSKYlW2LuZE2mV5kqS|)abL8=< z=%>+n-5Kd;MnV2TCEfy&e#p?_l6r&dXE+0mSQZgFTZoc@@u`^>(|ino@?Ol^7Si_ zHe5l~?Y_Qru~xc`?J-Khoj%^gC1b+8!+pi^rhkp0syl;m^E(`?+6}(p;(RU!w;$HWQVLd$P2Q2hyIr+_zcGL} zuf}QbcgYpW(*xxaiImjQ-W^YNcO|>9D+@=>uY}zJ(qOe7bR@Oi(|dfoKZfvZs9fWH zJigtX9Te?eQKUNw +#include +#include +#include +#include +#include +#include "utils.h" +#include "main.h" +#include "uart.h" + +#define BUFSIZE 40 +#define CURRENT_MAX 30000 // 30 Ampere is max + +volatile uint16_t syscounter = 0; +volatile uint8_t digitbuffer[6] = { 0,0,0,0,0,0 }; +volatile uint8_t leddigitbuffer[4] = { 0,0,0,0 }; +uint8_t digit = 0; +uint8_t leddigit = 0; + +// values send over uart from powerboard +uint16_t voltage = 0; +int16_t current_in = 0; +int16_t current_out = 0; +uint8_t dumpsw = 0; //TODO: make bitfield +uint8_t loadsw = 0; //TODO: make bitfield +uint8_t gensw = 0; //TODO: make bitfield +uint16_t display = 0; + +uint16_t power_gen = 0; +uint16_t power_load = 0; + +unsigned char data_count = 0; +unsigned char data_in[BUFSIZE]; +char command_in[BUFSIZE]; + +const uint8_t segment_translate[10] = { + 63, 6, 91, 79, 102, 109, 125, 7, 127, 111 +}; + +const uint8_t smallbar_translate[9] = { + 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff +}; + +const uint8_t bigbar_translate[15][2] = { + { 0x00, 0xc0}, + { 0x00, 0x60}, + { 0x00, 0x30}, + { 0x00, 0x18}, + { 0x00, 0x0c}, + { 0x00, 0x06}, + { 0x00, 0x03}, + { 0x01, 0x01}, + { 0x03, 0x00}, + { 0x06, 0x00}, + { 0x0c, 0x00}, + { 0x18, 0x00}, + { 0x30, 0x00}, + { 0x60, 0x00}, + { 0xc0, 0x00} +}; + + + +//static void timer_init(void) { + // clock is 8MHz + //TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64 + //OCR1A = 250; // 500Hz + //TIMSK = _BV(OCIE1A); + //sei(); // enable interrupts +//} +// Timer init +ISR( TIMER1_COMPA_vect ) // Interruptbehandlungsroutine +{ + OCR1A = 2500-OCR1A; // Das Servosignal wird aus der Differenz von + // Periodenlänge (2500*0,008ms=20ms) und letztem + // Vergleichswert (OCR1A) gebildet +} + +static void ports_init(void) { + // make column / digit driver pins to output + DDRB = 0b11111100; + PORTB = (1<= 100) { + uart_putc('a'); // send a to receive values + set_servo(power_gen) + + + + syscounter = 0; + } + } + + return(0); +} + +// system timer +SIGNAL(TIMER1_COMPA_vect) { + syscounter++; + + // output to sevensegment and leds + // make this here to reduce display flicker + digit++; + if(digit >5) digit = 0; + leddigit++; + if(leddigit >3) leddigit = 0; + + SEVENSEG_PORT = digitbuffer[digit]; + SEVENSEGDIG_PORT = _BV(digit+DIG0); + + LED_PORT = leddigitbuffer[leddigit]; + LEDDIG_PORT = _BV(leddigit); +} + + diff --git a/display_v2/software/displayboard/src/main.h b/display_v2/software/displayboard/src/main.h new file mode 100644 index 0000000..f4f9033 --- /dev/null +++ b/display_v2/software/displayboard/src/main.h @@ -0,0 +1,29 @@ +#ifndef _main_h + #define _main_h + + #define SEVENSEG_PORT PORTA + #define SEVENSEG_DDR DDRA + + #define LED_PORT PORTC + #define LED_DDR DDRC + + #define DIG0 PD2 + #define DIG1 PD3 + #define DIG2 PD4 + #define DIG3 PD5 + #define DIG4 PD6 + #define DIG5 PD7 + #define LEDS_MID1 PB0 + #define LEDS_MID2 PB1 + #define LEDS_LOAD PB2 + #define LEDS_GEN PB3 + + #define SEVENSEGDIG_PORT PORTD + #define SEVENSEGDIG_DDR DDRD + + #define LEDDIG_PORT PORTB + #define LEDDIG_DDR DDRB + + +#endif + diff --git a/display_v2/software/displayboard/src/uart.c b/display_v2/software/displayboard/src/uart.c new file mode 100644 index 0000000..c29ef62 --- /dev/null +++ b/display_v2/software/displayboard/src/uart.c @@ -0,0 +1,479 @@ +/************************************************************************* +Title: Interrupt UART library with receive/transmit circular buffers +Author: Peter Fleury http://jump.to/fleury +File: $Id: uart.c,v 1.10 2013/06/02 07:27:04 peter Exp $ +Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher +Hardware: any AVR with built-in UART, +License: GNU General Public License + +DESCRIPTION: + An interrupt is generated when the UART has finished transmitting or + receiving a byte. The interrupt handling routines use circular buffers + for buffering received and transmitted data. + + The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define + the buffer size in bytes. Note that these variables must be a + power of 2. + +USAGE: + Refere to the header file uart.h for a description of the routines. + See also example test_uart.c. + +NOTES: + Based on Atmel Application Note AVR306 + +LICENSE: + Copyright (C) 2006 Peter Fleury + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*************************************************************************/ +#include +#include +#include +#include "uart.h" + + +/* + * constants and macros + */ + +/* size of RX/TX buffers */ +#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1) +#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1) + +#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK ) +#error RX buffer size is not a power of 2 +#endif +#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK ) +#error TX buffer size is not a power of 2 +#endif + +#if defined(__AVR_AT90S2313__) \ + || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ + || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ + || defined(__AVR_ATmega103__) + /* old AVR classic or ATmega103 with one UART */ + #define AT90_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS USR + #define UART0_CONTROL UCR + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) + /* old AVR classic with one UART */ + #define AT90_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ + || defined(__AVR_ATmega323__) + /* ATmega with one USART */ + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RXC_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega163__) + /* ATmega163 with one UART */ + #define ATMEGA_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega162__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect + #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega161__) + /* ATmega with UART */ + #error "AVR ATmega161 currently not supported by this libaray !" +#elif defined(__AVR_ATmega169__) + /* ATmega with one USART */ + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ + || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATtiny2313__) + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega329__) || \ + defined(__AVR_ATmega649__) || \ + defined(__AVR_ATmega325__) || \ + defined(__AVR_ATmega645__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) +/* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega644__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#else + #error "no UART definition for MCU available" +#endif + + +/* + * module global variables + */ +static volatile unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE]; +static volatile unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE]; +static volatile unsigned char UART_TxHead; +static volatile unsigned char UART_TxTail; +static volatile unsigned char UART_RxHead; +static volatile unsigned char UART_RxTail; +static volatile unsigned char UART_LastRxError; + +#if defined( ATMEGA_USART1 ) +static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE]; +static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE]; +static volatile unsigned char UART1_TxHead; +static volatile unsigned char UART1_TxTail; +static volatile unsigned char UART1_RxHead; +static volatile unsigned char UART1_RxTail; +static volatile unsigned char UART1_LastRxError; +#endif + + + +ISR (UART0_RECEIVE_INTERRUPT) +/************************************************************************* +Function: UART Receive Complete interrupt +Purpose: called when the UART has received a character +**************************************************************************/ +{ + unsigned char tmphead; + unsigned char data; + unsigned char usr; + unsigned char lastRxError; + + + /* read UART status register and UART data register */ + usr = UART0_STATUS; + data = UART0_DATA; + + /* */ +#if defined( AT90_UART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#elif defined( ATMEGA_USART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#elif defined( ATMEGA_USART0 ) + lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); +#elif defined ( ATMEGA_UART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#endif + + /* calculate buffer index */ + tmphead = ( UART_RxHead + 1) & UART_RX_BUFFER_MASK; + + if ( tmphead == UART_RxTail ) { + /* error: receive buffer overflow */ + lastRxError = UART_BUFFER_OVERFLOW >> 8; + }else{ + /* store new index */ + UART_RxHead = tmphead; + /* store received data in buffer */ + UART_RxBuf[tmphead] = data; + } + UART_LastRxError |= lastRxError; +} + + +ISR (UART0_TRANSMIT_INTERRUPT) +/************************************************************************* +Function: UART Data Register Empty interrupt +Purpose: called when the UART is ready to transmit the next byte +**************************************************************************/ +{ + unsigned char tmptail; + + + if ( UART_TxHead != UART_TxTail) { + /* calculate and store new buffer index */ + tmptail = (UART_TxTail + 1) & UART_TX_BUFFER_MASK; + UART_TxTail = tmptail; + /* get one byte from buffer and write it to UART */ + UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ + }else{ + /* tx buffer empty, disable UDRE interrupt */ + UART0_CONTROL &= ~_BV(UART0_UDRIE); + } +} + + +/************************************************************************* +Function: uart_init() +Purpose: initialize UART and set baudrate +Input: baudrate using macro UART_BAUD_SELECT() +Returns: none +**************************************************************************/ +void uart_init(unsigned int baudrate) +{ + UART_TxHead = 0; + UART_TxTail = 0; + UART_RxHead = 0; + UART_RxTail = 0; + +#if defined( AT90_UART ) + /* set baud rate */ + UBRR = (unsigned char)baudrate; + + /* enable UART receiver and transmmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); + +#elif defined (ATMEGA_USART) + /* Set baud rate */ + if ( baudrate & 0x8000 ) + { + UART0_STATUS = (1<>8); + UBRRL = (unsigned char) baudrate; + + /* Enable USART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|(1<>8); + UBRR0L = (unsigned char) baudrate; + + /* Enable USART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE0)|(1<>8); + UBRR = (unsigned char) baudrate; + + /* Enable UART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|(1< http://jump.to/fleury +File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ +Software: AVR-GCC 4.1, AVR Libc 1.4 +Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz +License: GNU General Public License +Usage: see Doxygen manual + +LICENSE: + Copyright (C) 2006 Peter Fleury + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +************************************************************************/ + +/** + * @defgroup pfleury_uart UART Library + * @code #include @endcode + * + * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. + * + * This library can be used to transmit and receive data through the built in UART. + * + * An interrupt is generated when the UART has finished transmitting or + * receiving a byte. The interrupt handling routines use circular buffers + * for buffering received and transmitted data. + * + * The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define + * the size of the circular buffers in bytes. Note that these constants must be a power of 2. + * You may need to adapt this constants to your target and your application by adding + * CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile. + * + * @note Based on Atmel Application Note AVR306 + * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury + */ + +/**@{*/ + + +#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 +#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" +#endif + + +/* +** constants and macros +*/ + +/** @brief UART Baudrate Expression + * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz + * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 + */ +#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) + +/** @brief UART Baudrate Expression for ATmega double speed mode + * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz + * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 + */ +#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) + + +/** Size of the circular receive buffer, must be power of 2 */ +#ifndef UART_RX_BUFFER_SIZE +#define UART_RX_BUFFER_SIZE 32 +#endif +/** Size of the circular transmit buffer, must be power of 2 */ +#ifndef UART_TX_BUFFER_SIZE +#define UART_TX_BUFFER_SIZE 32 +#endif + +/* test if the size of the circular buffers fits into SRAM */ +#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) +#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM" +#endif + +/* +** high byte error return code of uart_getc() +*/ +#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ +#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ +#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ +#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ +#define UART_NO_DATA 0x0100 /* no receive data available */ + + +/* +** function prototypes +*/ + +/** + @brief Initialize UART and set baudrate + @param baudrate Specify baudrate using macro UART_BAUD_SELECT() + @return none +*/ +extern void uart_init(unsigned int baudrate); + + +/** + * @brief Get received byte from ringbuffer + * + * Returns in the lower byte the received character and in the + * higher byte the last receive error. + * UART_NO_DATA is returned when no data is available. + * + * @param void + * @return lower byte: received byte from ringbuffer + * @return higher byte: last receive status + * - \b 0 successfully received data from UART + * - \b UART_NO_DATA + *
no receive data available + * - \b UART_BUFFER_OVERFLOW + *
Receive ringbuffer overflow. + * We are not reading the receive buffer fast enough, + * one or more received character have been dropped + * - \b UART_OVERRUN_ERROR + *
Overrun condition by UART. + * A character already present in the UART UDR register was + * not read by the interrupt handler before the next character arrived, + * one or more received characters have been dropped. + * - \b UART_FRAME_ERROR + *
Framing Error by UART + */ +extern unsigned int uart_getc(void); + + +/** + * @brief Put byte to ringbuffer for transmitting via UART + * @param data byte to be transmitted + * @return none + */ +extern void uart_putc(unsigned char data); + + +/** + * @brief Put string to ringbuffer for transmitting via UART + * + * The string is buffered by the uart library in a circular buffer + * and one character at a time is transmitted to the UART using interrupts. + * Blocks if it can not write the whole string into the circular buffer. + * + * @param s string to be transmitted + * @return none + */ +extern void uart_puts(const char *s ); + + +/** + * @brief Put string from program memory to ringbuffer for transmitting via UART. + * + * The string is buffered by the uart library in a circular buffer + * and one character at a time is transmitted to the UART using interrupts. + * Blocks if it can not write the whole string into the circular buffer. + * + * @param s program memory string to be transmitted + * @return none + * @see uart_puts_P + */ +extern void uart_puts_p(const char *s ); + +/** + * @brief Macro to automatically put a string constant into program memory + */ +#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) + + + + +#endif // UART_H + diff --git a/display_v2/software/displayboard/src/utils.c b/display_v2/software/displayboard/src/utils.c new file mode 100644 index 0000000..6a5caca --- /dev/null +++ b/display_v2/software/displayboard/src/utils.c @@ -0,0 +1,39 @@ +#include +#include +#include "uart.h" + +void wait(uint8_t count) { + uint8_t i; + if(count == 0) count = 100; + for(i=0;i $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + +# Target: clean project. +clean: begin clean_list finished end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).a90 + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lnk + $(REMOVE) $(TARGET).lss + $(REMOVE) $(OBJ) + $(REMOVE) $(LST) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) .dep/* + + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff \ +clean clean_list program + diff --git a/display_v2/software/powerboard/powerboard.iml b/display_v2/software/powerboard/powerboard.iml new file mode 100644 index 0000000..7694e87 --- /dev/null +++ b/display_v2/software/powerboard/powerboard.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/display_v2/software/powerboard/src/adc.c b/display_v2/software/powerboard/src/adc.c new file mode 100644 index 0000000..8ad8969 --- /dev/null +++ b/display_v2/software/powerboard/src/adc.c @@ -0,0 +1,42 @@ +#include + + +void adc_init(void) { + uint16_t dummyResult; + // AVCC with external capacitor at AREF pin + ADMUX = _BV(REFS0); + + // set frequency prescaler to 8 + ADCSRA = _BV(ADPS1) | _BV(ADPS0); + + // enable ADC + ADCSRA |= _BV(ADEN); + + // make a dummy read out + ADCSRA |= _BV(ADSC); + while (ADCSRA & _BV(ADSC) ) { + } + + // we have to read, otherwise the next result is not available + dummyResult = ADCW; +} + + +uint16_t adc_read_single(uint8_t channel) { + ADMUX = (ADMUX & ~(0x1F)) | (channel & 0x1F); + ADCSRA |= _BV(ADSC); + while (ADCSRA & (1< +#include +#include +#include "utils.h" +#include "main.h" +#include "adc.h" +#include "uart.h" + +volatile uint16_t syscounter = 0; +uint16_t voltage = 0; +uint16_t current_in = 0; +uint16_t current_out = 0; + +uint8_t overvoltage_counter1 = 0; +uint8_t overvoltage_off_counter1 = 0; +uint8_t overvoltage_counter2 = 0; +uint8_t overvoltage_off_counter2 = 0; +uint8_t undervoltage_counter = 0; +uint8_t undervoltage_off_counter = 0; + + +static void timer_init(void) { + // clock is 8MHz + TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64 + OCR1A = 1250; // 100Hz + TIMSK = _BV(OCIE1A); + sei(); // enable interrupts +} + +static void ports_init(void) { + DDR_SW |= _BV(LOADSW) | _BV(GENSW) | _BV(DUMPSW); + PORT_SW &= ~(_BV(LOADSW) | _BV(GENSW) | _BV(DUMPSW)); +} + +void measure(void) { + static int16_t temp; + + voltage = adc_read_avg(AD_V, 4); + voltage *= VOLTAGE_PER_TICK; + + temp = adc_read_avg(AD_I_GEN, 4); + temp -= CURRENT_OFFSET; + if(temp < 0) temp = 0; + current_in = temp * CURRENT_PER_TICK; + + temp = adc_read_avg(AD_I_LOAD, 4); + temp -= CURRENT_OFFSET; + if(temp < 0) temp = 0; + current_out = temp * CURRENT_PER_TICK; +} + +uint16_t get_power(uint16_t voltage, int16_t currents) { + return (voltage/100 * (currents/100)) / 100 ; +} + + +void pretty_print_all_values(void) { + uart_puts_P("Voltage: "); + uart_print_uint16(voltage); + uart_puts_P("mV\r\n"); + + uart_puts_P("Load: "); + uart_print_uint16(current_out); + uart_puts_P("mA "); + uart_print_uint16( get_power(voltage, current_out)); + uart_puts_P("W\r\n"); + + uart_puts_P("Generator: "); + uart_print_uint16(current_in); + uart_puts_P("mA "); + uart_print_uint16(get_power(voltage, current_in)); + uart_puts_P("W\r\n"); + + uart_puts_P("switches (load, dump, gen): "); + uart_putc(48 + (IS_LOAD_ON >> LOADSW)); + uart_putc(','); + uart_putc(48 + (IS_DUMP_ON >> DUMPSW)); + uart_putc(','); + uart_putc(48 + (IS_GEN_ON >> GENSW)); + uart_puts_P("\r\n"); +} + +void handle_over_and_undervoltage(void) { + if(voltage > OVERVOLTAGE1) { + overvoltage_off_counter1 = 0; + if(overvoltage_counter1 OVERVOLTAGE2) { + overvoltage_off_counter2 = 0; + if(overvoltage_counter2= OVERVOLTAGE_TIMEOUT1) { + overvoltage_off_counter1 = 0; + DUMP_ON; + } + + if(overvoltage_off_counter1 >= OVERVOLTAGEOFF_TIMEOUT1) { + overvoltage_counter1 = 0; + DUMP_OFF; + } + + if(overvoltage_counter2 >= OVERVOLTAGE_TIMEOUT2) { + overvoltage_off_counter2 = 0; + GEN_OFF; + } + + if(overvoltage_off_counter2 >= OVERVOLTAGEOFF_TIMEOUT2) { + overvoltage_counter2 = 0; + GEN_ON; + } + + if(undervoltage_counter >= UNDERVOLTAGE_TIMEOUT) { + undervoltage_off_counter = 0; + overvoltage_off_counter1 = OVERVOLTAGEOFF_TIMEOUT1; + LOAD_OFF; + DUMP_OFF; + } + + if(undervoltage_off_counter >= UNDERVOLTAGEOFF_TIMEOUT) { + undervoltage_counter = 0; + LOAD_ON; + } + + +#ifdef DEBUG + uart_puts_P("ov1="); + uart_print_uint8(overvoltage_counter1); + uart_puts_P(" ovo1="); + uart_print_uint8 (overvoltage_off_counter1); + uart_puts_P("\r\n"); + + uart_puts_P("ov2="); + uart_print_uint8(overvoltage_counter2); + uart_puts_P(" ovo2="); + uart_print_uint8 (overvoltage_off_counter2); + uart_puts_P("\r\n"); + + uart_puts_P("uv ="); + uart_print_uint8(undervoltage_counter); + uart_puts_P(" uvo ="); + uart_print_uint8(undervoltage_off_counter); + uart_puts_P("\r\n"); +#endif + +} + +static void work_uart(void) { + uint16_t uart_char = uart_getc(); + + if(uart_char != UART_NO_DATA) { + switch(uart_char & 0xff) { + case 'p': + pretty_print_all_values(); + break; + case 'a': + uart_putc('A'); + uart_print_uint16(voltage); + uart_putc(','); + uart_print_uint16(current_in); + uart_putc(','); + uart_print_uint16(current_out); + uart_putc(','); + uart_print_uint16(get_power(voltage, current_in)); + uart_putc(','); + uart_print_uint16(get_power(voltage, current_out)); + uart_putc(','); + uart_putc(48 + (IS_LOAD_ON >> LOADSW)); + uart_putc(','); + uart_putc(48 + (IS_DUMP_ON >> DUMPSW)); + uart_putc(','); + uart_putc(48 + (IS_GEN_ON >> GENSW)); + uart_putc('B'); + break; + } + + } +} + + +int main(void) { + ports_init(); + adc_init(); + timer_init(); + uart_init(UART_BAUD_SELECT(19200,F_CPU)); + + LOAD_OFF; + GEN_ON; + DUMP_OFF; + + + while(1) { + + if(syscounter >= 100) { + syscounter = 0; + + measure(); + + //pretty_print_all_values(); + + handle_over_and_undervoltage(); + } + + work_uart(); + } + + return(0); +} + +// system timer +SIGNAL(TIMER1_COMPA_vect) { + syscounter++; + syscounter %= 60000; +} + + diff --git a/display_v2/software/powerboard/src/main.h b/display_v2/software/powerboard/src/main.h new file mode 100644 index 0000000..7834c55 --- /dev/null +++ b/display_v2/software/powerboard/src/main.h @@ -0,0 +1,41 @@ +#ifndef _main_h + #define _main_h + + #define AD_I_LOAD 0 + #define AD_I_GEN 1 + #define AD_V 2 + + #define LOADSW PB0 + #define GENSW PB1 + #define DUMPSW PB2 + #define PORT_SW PORTB + #define DDR_SW DDRB + #define PIN_SW PINB + + #define LOAD_ON PORT_SW |= _BV(LOADSW) + #define LOAD_OFF PORT_SW &= ~_BV(LOADSW) + #define GEN_ON PORT_SW |= _BV(GENSW) + #define GEN_OFF PORT_SW &= ~_BV(GENSW) + #define DUMP_ON PORT_SW |= _BV(DUMPSW) + #define DUMP_OFF PORT_SW &= ~_BV(DUMPSW) + + #define IS_LOAD_ON (PIN_SW & _BV(LOADSW)) + #define IS_DUMP_ON (PIN_SW & _BV(DUMPSW)) + #define IS_GEN_ON (PIN_SW & _BV(GENSW)) + + #define UNDERVOLTAGE 11200 + #define OVERVOLTAGE1 15000 + #define OVERVOLTAGE2 16500 + #define OVERVOLTAGE_TIMEOUT1 8 + #define OVERVOLTAGEOFF_TIMEOUT1 1 + #define OVERVOLTAGE_TIMEOUT2 6 + #define OVERVOLTAGEOFF_TIMEOUT2 3 + #define UNDERVOLTAGE_TIMEOUT 5 + #define UNDERVOLTAGEOFF_TIMEOUT 2 + + #define CURRENT_OFFSET 511 + #define CURRENT_PER_TICK 72 + #define VOLTAGE_PER_TICK 15.5 + +#endif + diff --git a/display_v2/software/powerboard/src/uart.c b/display_v2/software/powerboard/src/uart.c new file mode 100644 index 0000000..67f8581 --- /dev/null +++ b/display_v2/software/powerboard/src/uart.c @@ -0,0 +1,663 @@ +/************************************************************************* +Title: Interrupt UART library with receive/transmit circular buffers +Author: Peter Fleury http://jump.to/fleury +File: $Id: uart.c,v 1.10 2013/06/02 07:27:04 peter Exp $ +Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher +Hardware: any AVR with built-in UART, +License: GNU General Public License + +DESCRIPTION: + An interrupt is generated when the UART has finished transmitting or + receiving a byte. The interrupt handling routines use circular buffers + for buffering received and transmitted data. + + The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define + the buffer size in bytes. Note that these variables must be a + power of 2. + +USAGE: + Refere to the header file uart.h for a description of the routines. + See also example test_uart.c. + +NOTES: + Based on Atmel Application Note AVR306 + +LICENSE: + Copyright (C) 2006 Peter Fleury + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*************************************************************************/ +#include +#include +#include +#include "uart.h" + + +/* + * constants and macros + */ + +/* size of RX/TX buffers */ +#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1) +#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1) + +#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK ) +#error RX buffer size is not a power of 2 +#endif +#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK ) +#error TX buffer size is not a power of 2 +#endif + +#if defined(__AVR_AT90S2313__) \ + || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ + || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ + || defined(__AVR_ATmega103__) + /* old AVR classic or ATmega103 with one UART */ + #define AT90_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS USR + #define UART0_CONTROL UCR + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) + /* old AVR classic with one UART */ + #define AT90_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ + || defined(__AVR_ATmega323__) + /* ATmega with one USART */ + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RXC_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega163__) + /* ATmega163 with one UART */ + #define ATMEGA_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega162__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect + #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega161__) + /* ATmega with UART */ + #error "AVR ATmega161 currently not supported by this libaray !" +#elif defined(__AVR_ATmega169__) + /* ATmega with one USART */ + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ + || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATtiny2313__) + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega329__) || \ + defined(__AVR_ATmega649__) || \ + defined(__AVR_ATmega325__) || \ + defined(__AVR_ATmega645__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) +/* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega644__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#else + #error "no UART definition for MCU available" +#endif + + +/* + * module global variables + */ +static volatile unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE]; +static volatile unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE]; +static volatile unsigned char UART_TxHead; +static volatile unsigned char UART_TxTail; +static volatile unsigned char UART_RxHead; +static volatile unsigned char UART_RxTail; +static volatile unsigned char UART_LastRxError; + +#if defined( ATMEGA_USART1 ) +static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE]; +static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE]; +static volatile unsigned char UART1_TxHead; +static volatile unsigned char UART1_TxTail; +static volatile unsigned char UART1_RxHead; +static volatile unsigned char UART1_RxTail; +static volatile unsigned char UART1_LastRxError; +#endif + + + +ISR (UART0_RECEIVE_INTERRUPT) +/************************************************************************* +Function: UART Receive Complete interrupt +Purpose: called when the UART has received a character +**************************************************************************/ +{ + unsigned char tmphead; + unsigned char data; + unsigned char usr; + unsigned char lastRxError; + + + /* read UART status register and UART data register */ + usr = UART0_STATUS; + data = UART0_DATA; + + /* */ +#if defined( AT90_UART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#elif defined( ATMEGA_USART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#elif defined( ATMEGA_USART0 ) + lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); +#elif defined ( ATMEGA_UART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#endif + + /* calculate buffer index */ + tmphead = ( UART_RxHead + 1) & UART_RX_BUFFER_MASK; + + if ( tmphead == UART_RxTail ) { + /* error: receive buffer overflow */ + lastRxError = UART_BUFFER_OVERFLOW >> 8; + }else{ + /* store new index */ + UART_RxHead = tmphead; + /* store received data in buffer */ + UART_RxBuf[tmphead] = data; + } + UART_LastRxError |= lastRxError; +} + + +ISR (UART0_TRANSMIT_INTERRUPT) +/************************************************************************* +Function: UART Data Register Empty interrupt +Purpose: called when the UART is ready to transmit the next byte +**************************************************************************/ +{ + unsigned char tmptail; + + + if ( UART_TxHead != UART_TxTail) { + /* calculate and store new buffer index */ + tmptail = (UART_TxTail + 1) & UART_TX_BUFFER_MASK; + UART_TxTail = tmptail; + /* get one byte from buffer and write it to UART */ + UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ + }else{ + /* tx buffer empty, disable UDRE interrupt */ + UART0_CONTROL &= ~_BV(UART0_UDRIE); + } +} + + +/************************************************************************* +Function: uart_init() +Purpose: initialize UART and set baudrate +Input: baudrate using macro UART_BAUD_SELECT() +Returns: none +**************************************************************************/ +void uart_init(unsigned int baudrate) +{ + UART_TxHead = 0; + UART_TxTail = 0; + UART_RxHead = 0; + UART_RxTail = 0; + +#if defined( AT90_UART ) + /* set baud rate */ + UBRR = (unsigned char)baudrate; + + /* enable UART receiver and transmmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); + +#elif defined (ATMEGA_USART) + /* Set baud rate */ + if ( baudrate & 0x8000 ) + { + UART0_STATUS = (1<>8); + UBRRL = (unsigned char) baudrate; + + /* Enable USART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|(1<>8); + UBRR0L = (unsigned char) baudrate; + + /* Enable USART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE0)|(1<>8); + UBRR = (unsigned char) baudrate; + + /* Enable UART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|(1<> 8; + }else{ + /* store new index */ + UART1_RxHead = tmphead; + /* store received data in buffer */ + UART1_RxBuf[tmphead] = data; + } + UART1_LastRxError |= lastRxError; +} + + +ISR(UART1_TRANSMIT_INTERRUPT) +/************************************************************************* +Function: UART1 Data Register Empty interrupt +Purpose: called when the UART1 is ready to transmit the next byte +**************************************************************************/ +{ + unsigned char tmptail; + + + if ( UART1_TxHead != UART1_TxTail) { + /* calculate and store new buffer index */ + tmptail = (UART1_TxTail + 1) & UART_TX_BUFFER_MASK; + UART1_TxTail = tmptail; + /* get one byte from buffer and write it to UART */ + UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ + }else{ + /* tx buffer empty, disable UDRE interrupt */ + UART1_CONTROL &= ~_BV(UART1_UDRIE); + } +} + + +/************************************************************************* +Function: uart1_init() +Purpose: initialize UART1 and set baudrate +Input: baudrate using macro UART_BAUD_SELECT() +Returns: none +**************************************************************************/ +void uart1_init(unsigned int baudrate) +{ + UART1_TxHead = 0; + UART1_TxTail = 0; + UART1_RxHead = 0; + UART1_RxTail = 0; + + + /* Set baud rate */ + if ( baudrate & 0x8000 ) + { + UART1_STATUS = (1<>8); + UBRR1L = (unsigned char) baudrate; + + /* Enable USART receiver and transmitter and receive complete interrupt */ + UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury +File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ +Software: AVR-GCC 4.1, AVR Libc 1.4 +Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz +License: GNU General Public License +Usage: see Doxygen manual + +LICENSE: + Copyright (C) 2006 Peter Fleury + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +************************************************************************/ + +/** + * @defgroup pfleury_uart UART Library + * @code #include @endcode + * + * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. + * + * This library can be used to transmit and receive data through the built in UART. + * + * An interrupt is generated when the UART has finished transmitting or + * receiving a byte. The interrupt handling routines use circular buffers + * for buffering received and transmitted data. + * + * The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define + * the size of the circular buffers in bytes. Note that these constants must be a power of 2. + * You may need to adapt this constants to your target and your application by adding + * CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile. + * + * @note Based on Atmel Application Note AVR306 + * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury + */ + +/**@{*/ + + +#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 +#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" +#endif + + +/* +** constants and macros +*/ + +/** @brief UART Baudrate Expression + * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz + * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 + */ +#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) + +/** @brief UART Baudrate Expression for ATmega double speed mode + * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz + * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 + */ +#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) + + +/** Size of the circular receive buffer, must be power of 2 */ +#ifndef UART_RX_BUFFER_SIZE +#define UART_RX_BUFFER_SIZE 32 +#endif +/** Size of the circular transmit buffer, must be power of 2 */ +#ifndef UART_TX_BUFFER_SIZE +#define UART_TX_BUFFER_SIZE 32 +#endif + +/* test if the size of the circular buffers fits into SRAM */ +#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) +#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM" +#endif + +/* +** high byte error return code of uart_getc() +*/ +#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ +#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ +#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ +#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ +#define UART_NO_DATA 0x0100 /* no receive data available */ + + +/* +** function prototypes +*/ + +/** + @brief Initialize UART and set baudrate + @param baudrate Specify baudrate using macro UART_BAUD_SELECT() + @return none +*/ +extern void uart_init(unsigned int baudrate); + + +/** + * @brief Get received byte from ringbuffer + * + * Returns in the lower byte the received character and in the + * higher byte the last receive error. + * UART_NO_DATA is returned when no data is available. + * + * @param void + * @return lower byte: received byte from ringbuffer + * @return higher byte: last receive status + * - \b 0 successfully received data from UART + * - \b UART_NO_DATA + *
no receive data available + * - \b UART_BUFFER_OVERFLOW + *
Receive ringbuffer overflow. + * We are not reading the receive buffer fast enough, + * one or more received character have been dropped + * - \b UART_OVERRUN_ERROR + *
Overrun condition by UART. + * A character already present in the UART UDR register was + * not read by the interrupt handler before the next character arrived, + * one or more received characters have been dropped. + * - \b UART_FRAME_ERROR + *
Framing Error by UART + */ +extern unsigned int uart_getc(void); + + +/** + * @brief Put byte to ringbuffer for transmitting via UART + * @param data byte to be transmitted + * @return none + */ +extern void uart_putc(unsigned char data); + + +/** + * @brief Put string to ringbuffer for transmitting via UART + * + * The string is buffered by the uart library in a circular buffer + * and one character at a time is transmitted to the UART using interrupts. + * Blocks if it can not write the whole string into the circular buffer. + * + * @param s string to be transmitted + * @return none + */ +extern void uart_puts(const char *s ); + + +/** + * @brief Put string from program memory to ringbuffer for transmitting via UART. + * + * The string is buffered by the uart library in a circular buffer + * and one character at a time is transmitted to the UART using interrupts. + * Blocks if it can not write the whole string into the circular buffer. + * + * @param s program memory string to be transmitted + * @return none + * @see uart_puts_P + */ +extern void uart_puts_p(const char *s ); + +/** + * @brief Macro to automatically put a string constant into program memory + */ +#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) + + + + +#endif // UART_H + diff --git a/display_v2/software/powerboard/src/utils.c b/display_v2/software/powerboard/src/utils.c new file mode 100644 index 0000000..466bfec --- /dev/null +++ b/display_v2/software/powerboard/src/utils.c @@ -0,0 +1,36 @@ +#include +#include +#include "uart.h" + +void wait(uint8_t count) { + uint8_t i; + if(count == 0) count = 100; + for(i=0;i $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + +# Target: clean project. +clean: begin clean_list finished end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).a90 + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lnk + $(REMOVE) $(TARGET).lss + $(REMOVE) $(OBJ) + $(REMOVE) $(LST) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) .dep/* + + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff \ +clean clean_list program + diff --git a/display_v2/software/powerboard_v2/main.eep b/display_v2/software/powerboard_v2/main.eep new file mode 100644 index 0000000..7c166a1 --- /dev/null +++ b/display_v2/software/powerboard_v2/main.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/display_v2/software/powerboard_v2/main.elf b/display_v2/software/powerboard_v2/main.elf new file mode 100755 index 0000000000000000000000000000000000000000..8d36a7501ac83bb098e4770dc8b644b8909bf869 GIT binary patch literal 7652 zcmcJUeRP!7oyYGZFNy8iOsXv&<8DSb3#dJL!4M!K2n4W54e}=I79XC>Jb8i1%w%T5 zi_6LcFp!v%XJ!}@z%{m8X-m7V(QR#x3qGi4SC?Wk=;>*<3-b^$t6L6)EvMAllKuXk zxA`TzXV3oQ)jRj|z4v#2_jg~Ox3FvJ%4L!y2`Ako)(A&cqS9L+#9ow@!YghPGsVqf zs@WcMI-so1v+@)$^`-n0>NbhEnIXkG=cSL=`ItMpoZ(W!6fEA>b875W2j z*1x%2U#2hBYxE`hVtug^i>Z+v-u0nCOleT7yhj5FFw$p zcj5Zcv&-H(J~){28@r8~%%Jg{^k$zfz164PQdrXY6FEKr9sRmfpi@`*G zdN7quU6M{qB_rj=fOP5XXVQDpfb_xH5m^5Rtbc3v7?4h%JuPJu)T4b^GiIHQCpHT$ zu|;gmbbhEA_nz&>?+ny7qP9t_&OGyxW)z?8#P6M`tw(KxSe|Jg(Tv+%ZH@T~#&o<5 zNIm~!qI=^6VH@4Uh9_QDWA9*E8|05o!C=;yIDsTR@5EylS@{OdXhL(2?gy|AI0pWpl*|B zE1aaa8SxZZkk{K`T_*~3%iks_@=bj`qxzBjwADxN%}*C63z7vtDM%KUl%*D?YEyD5 zl-iZ*PW7eYi2zooSxASpR5SJ^fISOf&zeP>p&8z)6_+dXJlEpjO(RcTZtr_R+Sj-0 zmP5#eCGSdmi_%|o`t>Ec6T1?jgq)~NEKHOo3bcZg1zNFodpdq`-@qQDePGU!sv}j0 zZw&73Pxt4id-}Uuw5L1n+c#j*(gpFB*wJ-bX%dM@5N4Cxp3oRMbFjiLKmV> z?!EQ;V1D{aGUvTZ+H_&t@bj6SQhQl^aTX`fymtPz{4)Q@mP~x(;XVI6bcb=ct)omS^FhBc6bC(->44V) z&GGP$I*;X&8OsJcmSaQtmv2QZKb30DQJ)`r5B&Aa3sKT&#$D$QqT53*T28TNJPXH`AUm7(ISSY%^NjR5ix4~dc#<) zwnx%;8(JbPdhgRxVKJ7tlAs;t`q&-1xp9;3H7X1`PZU$1+=n?vMRMAO-+WSLN3%yu#l$*XCv?^>Ns|7b z*^We8;U5NR^>Ve@><#IzLwnKkd%I=dt9v%>dwu__UAy+bo;ZKt$Ios$aANo6gT~Pl zohRZKI^NiRu;YSeq_cYOsUvTX3>nTfwzn!Vr5smjGhz&gCFedq*OP7g%3Ve>ujMy~ zXSAX9p3(T6#FTm0yUu+y*mm(dS?7N8$@#9~qfpkJY#8cbmafTjpl-MRr1Z$pQTJ|k zQYs&sj{E2g+(WC(`{+q&#?Wc$E%a$Md!Gb_v)27AknI}YoQ;3jh_W7a)_qOM?!G8z z`vwme?Jy?mhl>wQ%O5>dw7>YN^t;#N>HPHZqSuQayO5_JFMhrF*tFO3Jfp{oUi;$y z;={#Hq<;VlE&Wf@8SFvNXL+Sxy(SJ$9oqKC{Gp54ygy7CT5wHEx25}P^V8w9lHP^# zcL&D?t>>o@npkT;OZ_O1BNrmaktr1+mx%jKo{3+2emkiKPjV;Kh}n3iTd77=iODX{ zF`v~WYs6fU@7B)~cxalbMpTPGarpu9C70(5kIN5=FT1=z+~)E^@l}@}61Tg&NZjG_ zVsWR-OT?eKTqC?LFBNyYybN=;QjJ(Hrn~$wkNjQ@`DcNxFP_!#5wG5$W|A22@7_=k*t#Q5(Szr^?- z7{AQ8pYbb4N0M&pWY2=ui_)ZVBa`MMkakwdG>4wzt^?If7FWk8&fL7Nj?ugyq((Dc z9i#V?M*-Dc5 zA>esOqWz@HpU?Wd{W<&p+2`#4efY=M6;_JY^Cpo+*~0X%p;R=$!wn zV;#^XXs2%vn%`k)4f$zXe;3T-`w6t;pXPfCn)`cyf_)bH$B2)T2lM{~`bS{8ZfU%$ z&@bU)rt6>dXV3>QU%D@l&O>a@_%z;^px=f)-Iu8S4(KPa7<3Jjo(0Y0TQEVdn4s4| zm%|_J2lbbs4}s~PP3sqg-ib`#VALK33(-bDXrCnFrZ%N%-^nz^dlcG(^EBPGm&Es= zd3>)xJM*LQbm$F;rxNxw-oHZAep90L`#JP^wEq`0wf_p5`=hg}vh(nJ=q}jbZQD=A z+HOWWmf1W%9%v_daX&AD=KiKn&=t_X!+Q6k6OI2UH0_DAe~&|#AaAzYo50*(D>VN8 zh@RH?ozO$L9_akh{Cl7~!IVh9I6?PA%gB@{-T`oKeXxGe0g;>EY3SVfn@qG$S`$vi5xdB~|c4z%=#@aglsl5Q2`!AZHXH3xdPtXgY=VLt| z!g#d4qFHGQmiq9Dw`P_6uq<1!(t_1Xmz#jsM>(Q4nEaF)3E3j1Hit_qX3wocCm zr2}rwT&t$4yxf6V4%o(3<+gEExno>WE=v6&*%wfih>W*J883|yyg-ht3xq;pq4<4> zy*1Vph*AkF6zdkPUMsKO{;;a}9bT(61sq=7T5sV>B^q13eQ6{TidYqES)aArbA8rs zr#`aW>TlZG9P+m`Rmy63yf&k8EgC0SkhU!>7gP~c8|eLeTm>you0q}36hlQc77EMZ zNT?yAG@EmTz`MBIil4c7mpA{}M#jIkz}9-3mn%er8k57JZE6H$|1*y43$@ZKJk0Ew zAPk5Y{Dwn;rl9Jqw5*zM>^XO{n3qs}z3VBoRgE|S@cIcK3_NPv9OL?xn1W@&mxUVi z(^leGK}4H^4FNSb7djq1L^5_GyMLS?>zu$debJa+5eUu?b!k?WXlq2ZLurjgb51H~ zADV(#Y&t=57>#mRgd=J!w!>a)B@mFeDuGs&cca0b1)r1SIhGsKA!1<%S!`3x9aU9q zXR{rk{Q;Ki?^o-U)&T9idlYhwvw`LZn|)E35o5FI3eH_BbW!K}R0_UN&M9!_>T{1! zokD{)s!DiVX!5+At68E^3Hk%7Ode&R+#2+|XTaPlC*4CrWw?)V*ogWe15p^asKIpl^ynMzDHSUOFafPon62a#uHXr`1tIdg$ UVsMylUJmn_%*~xzWov`@Z#fC+xBvhE literal 0 HcmV?d00001 diff --git a/display_v2/software/powerboard_v2/main.hex b/display_v2/software/powerboard_v2/main.hex new file mode 100644 index 0000000..0fc2904 --- /dev/null +++ b/display_v2/software/powerboard_v2/main.hex @@ -0,0 +1,117 @@ +:1000000044C053C052C051C050C04FC041C14DC088 +:100010004CC04BC04AC03BC266C247C046C045C088 +:1000200044C043C042C04261747465727920566F07 +:100030006C746167653A202020006D560D0A0047F8 +:10004000656E657261746F7220566F6C746167655E +:100050003A202020006D560D0A0047656E657261DA +:10006000746F723A20006D41202000570D0A007312 +:100070007769746368657320286C6F61642C2067EE +:10008000656E293A20000D0A000011241FBECFE53D +:10009000D4E0DEBFCDBF10E0A0E6B0E001C01D920D +:1000A000A53BB107E1F79BD246C3AACFCF9364E04B +:1000B00082E044D1CFE09C01C29FC001C39F900D5C +:1000C00011248A5E9C4F90936B0080936A0064E0D9 +:1000D00080E034D19C01C29FC001C39F900D1124C8 +:1000E000909369008093680064E081E027D18F5F7E +:1000F000914097FD05C090936F0080936E0004C0FF +:1001000010926F0010926E0020916E0030916F007F +:1001100048E4429FC001439F900D112490936700D3 +:1001200080936600CF910895CF93DF93EC01CB01CC +:1001300024E630E0B901ECD2FB01CE01B901D4D202 +:10014000E69FC001E79F900DF69F900D1124B90125 +:10015000CBD2CB01DF91CF91089586E290E032D2ED +:1001600080916A0090916B005DD18AE390E02AD281 +:100170008FE390E027D2809168009091690052D17E +:1001800085E590E01FD28AE590E01CD28091660060 +:100190009091670047D186E690E014D28091660086 +:1001A0009091670024E630E0B901B2D2FB01809162 +:1001B0006A0090916B00B90197D2E69FC001E79F5A +:1001C000900DF69F900D1124B9018ED2CB012AD14A +:1001D0008BE690E0F7D18FE690E0F4D186B38170A2 +:1001E000805DD4D18CE2D2D186B386958170805D5A +:1001F000CDD186E890E0E6C180916A0090916B00D5 +:10020000803C9B4250F410926200809163008530E4 +:1002100068F48F5F8093630009C01092630080913F +:100220006200833018F48F5F8093620080916800D1 +:1002300090916900893C924350F010926000809147 +:100240006100833068F48F5F8093610009C0109271 +:10025000610080916000811103C081E080936000A3 +:1002600080916300853018F0109262000FC0809179 +:100270006200833060F010926300809161008330EF +:1002800010F0C09A0895809160008111C09808957F +:100290001F920F920FB60F9211242F933F934F93FB +:1002A0005F936F937F938F939F9380916C00909156 +:1002B0006D00019690936D0080936C0020916C000E +:1002C00030916D0081E090E020364AEE340710F462 +:1002D00080E090E060E67AEE869FA001879F500D57 +:1002E000969F500D1124C901841B950B90936D00AE +:1002F00080936C009F918F917F916F915F914F914F +:100300003F912F910F900FBE0F901F90189580E492 +:1003100087B983E086B9379A369A3699FECF84B189 +:1003200095B1089597B18F71907E892B87B9369AD0 +:100330003699FECF24B135B1C9010895FF920F93CC +:100340001F93CF93DF93082F862F6CE3C1D1F92E33 +:1003500010E0C0E0D0E005C0802FE4DFC80FD91F57 +:100360001F5F1F11F9CF612FCE0170E0BDD1CB010E +:10037000DF91CF911F910F91FF900895811101C0DE +:1003800084E690E0EFE1FEE43197F1F700C0000071 +:100390009F5F9813F7CF0895EF92FF920F931F93EB +:1003A000CF93DF938C0160E177E29ED17C01862FB1 +:1003B000805DECD0C8EED3E0C701BE0195D1862F99 +:1003C000805DE4D08EE2E2D0C801BE018DD164E64A +:1003D00070E08AD1862F805DDF91CF911F910F91C0 +:1003E000FF90EF90D3C00F931F93CF93DF931F9293 +:1003F000CDB7DEB7082F64E66BD1805D9983C6D098 +:100400001AE09981892F612F63D1805DBFD0802F41 +:10041000612F5ED1892F805D0F90DF91CF911F9169 +:100420000F91B4C0EF92FF920F931F93CF93DF937E +:10043000EC0160E177E258D17C01862F805DA6D087 +:1004400008EE13E0C701B8014FD1862F805D9ED022 +:10045000CE01B80149D104E610E0B80145D1862F9C +:10046000805D94D0CE01B8013FD10AE010E0B80120 +:100470003BD1862F805D8AD0CE01B80135D1805D19 +:10048000DF91CF911F910F91FF90EF907FC01F924E +:100490000F920FB60F9211242F938F939F93EF9388 +:1004A000FF938BB19CB18871E0917200EF5FEF71A7 +:1004B00020917100E21739F0E0937200F0E0EB5800 +:1004C000FF4F908301C082E090917000982B909331 +:1004D0007000FF91EF919F918F912F910F900FBE20 +:1004E0000F901F9018951F920F920FB60F92112424 +:1004F0008F939F93EF93FF9390917400809173007B +:10050000981761F0E0917300EF5FEF71E093730073 +:10051000F0E0EB56FF4F80818CB901C05598FF91F8 +:10052000EF919F918F910F900FBE0F901F90189594 +:100530001092740010927300109272001092710069 +:1005400097FF03C022E02BB99F7790BD89B988E956 +:100550008AB986E880BD08959091720080917100FB +:10056000981781F0E0917100EF5FEF71E0937100F7 +:10057000F0E0EB58FF4F20818091700010927000E6 +:1005800030E002C020E031E0C9010895909174008C +:100590009F5F9F71209173009217E1F3E92FF0E0C4 +:1005A000EB56FF4F808390937400559A0895CF9334 +:1005B000DF93EC0101C0EADF89918111FCCFDF916B +:1005C000CF910895CF93DF93EC0101C0DFDFFE01EF +:1005D000219684918111FACFDF91CF91089587B34D +:1005E000836087BB88B38C7F88BB91DE8EB58B60C0 +:1005F0008EBD82EE94E09BBD8ABD80E189BF789478 +:1006000089E190E095DFC098C19AC4E6D0E080917E +:100610006C0090916D008436910530F010926D0061 +:1006200010926C0043DDE8DD97DF811521E0920731 +:1006300071F399278136910529F08037910539F7B3 +:100640008CDDE5CF81E4A2DF80916A0090916B00A0 +:10065000E9DE8CE29BDF8091660090916700E2DE2C +:100660008CE294DF80E090E0DDDE8CE28FDF809131 +:10067000660090916700BE014BD09B0180916A009B +:1006800090916B00BE0130D0269FC001279F900D36 +:10069000369F900D1124BE0127D0CB01C3DE8CE222 +:1006A00075DF80E090E0BEDE8CE270DF86B38170A3 +:1006B000805D6CDF8CE26ADF80E368DF8CE266DFFE +:1006C00086B386958170805D61DF82E45FDF9FCFB6 +:1006D000991B79E004C0991F961708F0961B881F94 +:1006E0007A95C9F780950895AA1BBB1B51E107C0F5 +:1006F000AA1FBB1FA617B70710F0A61BB70B881FB2 +:10070000991F5A95A9F780959095BC01CD01089540 +:1007100097FB072E16F4009406D077FD08D0E4DF8F +:1007200007FC05D03EF4909581959F4F08957095F4 +:0A07300061957F4F0895F894FFCF04 +:00000001FF diff --git a/display_v2/software/powerboard_v2/main.lss b/display_v2/software/powerboard_v2/main.lss new file mode 100644 index 0000000..113b2f0 --- /dev/null +++ b/display_v2/software/powerboard_v2/main.lss @@ -0,0 +1,913 @@ + +main.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 0000073c 00000000 00000000 00000074 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .bss 00000055 00800060 00800060 000007b0 2**0 + ALLOC + 2 .stab 000006cc 00000000 00000000 000007b0 2**2 + CONTENTS, READONLY, DEBUGGING + 3 .stabstr 00000054 00000000 00000000 00000e7c 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .comment 00000011 00000000 00000000 00000ed0 2**0 + CONTENTS, READONLY + +Disassembly of section .text: + +00000000 <__vectors>: + 0: 44 c0 rjmp .+136 ; 0x8a <__ctors_end> + 2: 53 c0 rjmp .+166 ; 0xaa <__bad_interrupt> + 4: 52 c0 rjmp .+164 ; 0xaa <__bad_interrupt> + 6: 51 c0 rjmp .+162 ; 0xaa <__bad_interrupt> + 8: 50 c0 rjmp .+160 ; 0xaa <__bad_interrupt> + a: 4f c0 rjmp .+158 ; 0xaa <__bad_interrupt> + c: 42 c1 rjmp .+644 ; 0x292 <__vector_6> + e: 4d c0 rjmp .+154 ; 0xaa <__bad_interrupt> + 10: 4c c0 rjmp .+152 ; 0xaa <__bad_interrupt> + 12: 4b c0 rjmp .+150 ; 0xaa <__bad_interrupt> + 14: 4a c0 rjmp .+148 ; 0xaa <__bad_interrupt> + 16: 3c c2 rjmp .+1144 ; 0x490 <__vector_11> + 18: 67 c2 rjmp .+1230 ; 0x4e8 <__vector_12> + 1a: 47 c0 rjmp .+142 ; 0xaa <__bad_interrupt> + 1c: 46 c0 rjmp .+140 ; 0xaa <__bad_interrupt> + 1e: 45 c0 rjmp .+138 ; 0xaa <__bad_interrupt> + 20: 44 c0 rjmp .+136 ; 0xaa <__bad_interrupt> + 22: 43 c0 rjmp .+134 ; 0xaa <__bad_interrupt> + 24: 42 c0 rjmp .+132 ; 0xaa <__bad_interrupt> + +00000026 <__c.1594>: + 26: 42 61 74 74 65 72 79 20 56 6f 6c 74 61 67 65 3a Battery Voltage: + 36: 20 20 20 00 . + +0000003a <__c.1596>: + 3a: 6d 56 0d 0a 00 mV... + +0000003f <__c.1598>: + 3f: 47 65 6e 65 72 61 74 6f 72 20 56 6f 6c 74 61 67 Generator Voltag + 4f: 65 3a 20 20 20 00 e: . + +00000055 <__c.1600>: + 55: 6d 56 0d 0a 00 mV... + +0000005a <__c.1602>: + 5a: 47 65 6e 65 72 61 74 6f 72 3a 20 00 Generator: . + +00000066 <__c.1604>: + 66: 6d 41 20 20 00 mA . + +0000006b <__c.1606>: + 6b: 57 0d 0a 00 W... + +0000006f <__c.1608>: + 6f: 73 77 69 74 63 68 65 73 20 28 6c 6f 61 64 2c 20 switches (load, + 7f: 67 65 6e 29 3a 20 00 gen): . + +00000086 <__c.1610>: + 86: 0d 0a 00 00 .... + +0000008a <__ctors_end>: + 8a: 11 24 eor r1, r1 + 8c: 1f be out 0x3f, r1 ; 63 + 8e: cf e5 ldi r28, 0x5F ; 95 + 90: d4 e0 ldi r29, 0x04 ; 4 + 92: de bf out 0x3e, r29 ; 62 + 94: cd bf out 0x3d, r28 ; 61 + +00000096 <__do_clear_bss>: + 96: 10 e0 ldi r17, 0x00 ; 0 + 98: a0 e6 ldi r26, 0x60 ; 96 + 9a: b0 e0 ldi r27, 0x00 ; 0 + 9c: 01 c0 rjmp .+2 ; 0xa0 <.do_clear_bss_start> + +0000009e <.do_clear_bss_loop>: + 9e: 1d 92 st X+, r1 + +000000a0 <.do_clear_bss_start>: + a0: a5 3b cpi r26, 0xB5 ; 181 + a2: b1 07 cpc r27, r17 + a4: e1 f7 brne .-8 ; 0x9e <.do_clear_bss_loop> + a6: 9c d2 rcall .+1336 ; 0x5e0
+ a8: 47 c3 rjmp .+1678 ; 0x738 <_exit> + +000000aa <__bad_interrupt>: + aa: aa cf rjmp .-172 ; 0x0 <__vectors> + +000000ac : + ac: cf 93 push r28 + ae: 64 e0 ldi r22, 0x04 ; 4 + b0: 82 e0 ldi r24, 0x02 ; 2 + b2: 45 d1 rcall .+650 ; 0x33e + b4: cf e0 ldi r28, 0x0F ; 15 + b6: 9c 01 movw r18, r24 + b8: c2 9f mul r28, r18 + ba: c0 01 movw r24, r0 + bc: c3 9f mul r28, r19 + be: 90 0d add r25, r0 + c0: 11 24 eor r1, r1 + c2: 8a 5e subi r24, 0xEA ; 234 + c4: 9c 4f sbci r25, 0xFC ; 252 + c6: 90 93 6b 00 sts 0x006B, r25 + ca: 80 93 6a 00 sts 0x006A, r24 + ce: 64 e0 ldi r22, 0x04 ; 4 + d0: 80 e0 ldi r24, 0x00 ; 0 + d2: 35 d1 rcall .+618 ; 0x33e + d4: 9c 01 movw r18, r24 + d6: c2 9f mul r28, r18 + d8: c0 01 movw r24, r0 + da: c3 9f mul r28, r19 + dc: 90 0d add r25, r0 + de: 11 24 eor r1, r1 + e0: 90 93 69 00 sts 0x0069, r25 + e4: 80 93 68 00 sts 0x0068, r24 + e8: 64 e0 ldi r22, 0x04 ; 4 + ea: 81 e0 ldi r24, 0x01 ; 1 + ec: 28 d1 rcall .+592 ; 0x33e + ee: 8f 5f subi r24, 0xFF ; 255 + f0: 91 40 sbci r25, 0x01 ; 1 + f2: 97 fd sbrc r25, 7 + f4: 05 c0 rjmp .+10 ; 0x100 + f6: 90 93 6f 00 sts 0x006F, r25 + fa: 80 93 6e 00 sts 0x006E, r24 + fe: 04 c0 rjmp .+8 ; 0x108 + 100: 10 92 6f 00 sts 0x006F, r1 + 104: 10 92 6e 00 sts 0x006E, r1 + 108: 20 91 6e 00 lds r18, 0x006E + 10c: 30 91 6f 00 lds r19, 0x006F + 110: 48 e4 ldi r20, 0x48 ; 72 + 112: 42 9f mul r20, r18 + 114: c0 01 movw r24, r0 + 116: 43 9f mul r20, r19 + 118: 90 0d add r25, r0 + 11a: 11 24 eor r1, r1 + 11c: 90 93 67 00 sts 0x0067, r25 + 120: 80 93 66 00 sts 0x0066, r24 + 124: cf 91 pop r28 + 126: 08 95 ret + +00000128 : + 128: cf 93 push r28 + 12a: df 93 push r29 + 12c: ec 01 movw r28, r24 + 12e: cb 01 movw r24, r22 + 130: 24 e6 ldi r18, 0x64 ; 100 + 132: 30 e0 ldi r19, 0x00 ; 0 + 134: b9 01 movw r22, r18 + 136: ed d2 rcall .+1498 ; 0x712 <__divmodhi4> + 138: fb 01 movw r30, r22 + 13a: ce 01 movw r24, r28 + 13c: b9 01 movw r22, r18 + 13e: d5 d2 rcall .+1450 ; 0x6ea <__udivmodhi4> + 140: e6 9f mul r30, r22 + 142: c0 01 movw r24, r0 + 144: e7 9f mul r30, r23 + 146: 90 0d add r25, r0 + 148: f6 9f mul r31, r22 + 14a: 90 0d add r25, r0 + 14c: 11 24 eor r1, r1 + 14e: b9 01 movw r22, r18 + 150: cc d2 rcall .+1432 ; 0x6ea <__udivmodhi4> + 152: cb 01 movw r24, r22 + 154: df 91 pop r29 + 156: cf 91 pop r28 + 158: 08 95 ret + +0000015a : + 15a: 86 e2 ldi r24, 0x26 ; 38 + 15c: 90 e0 ldi r25, 0x00 ; 0 + 15e: 33 d2 rcall .+1126 ; 0x5c6 + 160: 80 91 6a 00 lds r24, 0x006A + 164: 90 91 6b 00 lds r25, 0x006B + 168: 5e d1 rcall .+700 ; 0x426 + 16a: 8a e3 ldi r24, 0x3A ; 58 + 16c: 90 e0 ldi r25, 0x00 ; 0 + 16e: 2b d2 rcall .+1110 ; 0x5c6 + 170: 8f e3 ldi r24, 0x3F ; 63 + 172: 90 e0 ldi r25, 0x00 ; 0 + 174: 28 d2 rcall .+1104 ; 0x5c6 + 176: 80 91 68 00 lds r24, 0x0068 + 17a: 90 91 69 00 lds r25, 0x0069 + 17e: 53 d1 rcall .+678 ; 0x426 + 180: 85 e5 ldi r24, 0x55 ; 85 + 182: 90 e0 ldi r25, 0x00 ; 0 + 184: 20 d2 rcall .+1088 ; 0x5c6 + 186: 8a e5 ldi r24, 0x5A ; 90 + 188: 90 e0 ldi r25, 0x00 ; 0 + 18a: 1d d2 rcall .+1082 ; 0x5c6 + 18c: 80 91 66 00 lds r24, 0x0066 + 190: 90 91 67 00 lds r25, 0x0067 + 194: 48 d1 rcall .+656 ; 0x426 + 196: 86 e6 ldi r24, 0x66 ; 102 + 198: 90 e0 ldi r25, 0x00 ; 0 + 19a: 15 d2 rcall .+1066 ; 0x5c6 + 19c: 80 91 66 00 lds r24, 0x0066 + 1a0: 90 91 67 00 lds r25, 0x0067 + 1a4: 24 e6 ldi r18, 0x64 ; 100 + 1a6: 30 e0 ldi r19, 0x00 ; 0 + 1a8: b9 01 movw r22, r18 + 1aa: b3 d2 rcall .+1382 ; 0x712 <__divmodhi4> + 1ac: fb 01 movw r30, r22 + 1ae: 80 91 6a 00 lds r24, 0x006A + 1b2: 90 91 6b 00 lds r25, 0x006B + 1b6: b9 01 movw r22, r18 + 1b8: 98 d2 rcall .+1328 ; 0x6ea <__udivmodhi4> + 1ba: e6 9f mul r30, r22 + 1bc: c0 01 movw r24, r0 + 1be: e7 9f mul r30, r23 + 1c0: 90 0d add r25, r0 + 1c2: f6 9f mul r31, r22 + 1c4: 90 0d add r25, r0 + 1c6: 11 24 eor r1, r1 + 1c8: b9 01 movw r22, r18 + 1ca: 8f d2 rcall .+1310 ; 0x6ea <__udivmodhi4> + 1cc: cb 01 movw r24, r22 + 1ce: 2b d1 rcall .+598 ; 0x426 + 1d0: 8b e6 ldi r24, 0x6B ; 107 + 1d2: 90 e0 ldi r25, 0x00 ; 0 + 1d4: f8 d1 rcall .+1008 ; 0x5c6 + 1d6: 8f e6 ldi r24, 0x6F ; 111 + 1d8: 90 e0 ldi r25, 0x00 ; 0 + 1da: f5 d1 rcall .+1002 ; 0x5c6 + 1dc: 86 b3 in r24, 0x16 ; 22 + 1de: 81 70 andi r24, 0x01 ; 1 + 1e0: 80 5d subi r24, 0xD0 ; 208 + 1e2: d5 d1 rcall .+938 ; 0x58e + 1e4: 8c e2 ldi r24, 0x2C ; 44 + 1e6: d3 d1 rcall .+934 ; 0x58e + 1e8: 86 b3 in r24, 0x16 ; 22 + 1ea: 86 95 lsr r24 + 1ec: 81 70 andi r24, 0x01 ; 1 + 1ee: 80 5d subi r24, 0xD0 ; 208 + 1f0: ce d1 rcall .+924 ; 0x58e + 1f2: 86 e8 ldi r24, 0x86 ; 134 + 1f4: 90 e0 ldi r25, 0x00 ; 0 + 1f6: e7 c1 rjmp .+974 ; 0x5c6 + +000001f8 : + 1f8: 80 91 6a 00 lds r24, 0x006A + 1fc: 90 91 6b 00 lds r25, 0x006B + 200: 80 3c cpi r24, 0xC0 ; 192 + 202: 9b 42 sbci r25, 0x2B ; 43 + 204: 50 f4 brcc .+20 ; 0x21a + 206: 10 92 62 00 sts 0x0062, r1 + 20a: 80 91 63 00 lds r24, 0x0063 + 20e: 85 30 cpi r24, 0x05 ; 5 + 210: 68 f4 brcc .+26 ; 0x22c + 212: 8f 5f subi r24, 0xFF ; 255 + 214: 80 93 63 00 sts 0x0063, r24 + 218: 09 c0 rjmp .+18 ; 0x22c + 21a: 10 92 63 00 sts 0x0063, r1 + 21e: 80 91 62 00 lds r24, 0x0062 + 222: 83 30 cpi r24, 0x03 ; 3 + 224: 18 f4 brcc .+6 ; 0x22c + 226: 8f 5f subi r24, 0xFF ; 255 + 228: 80 93 62 00 sts 0x0062, r24 + 22c: 80 91 68 00 lds r24, 0x0068 + 230: 90 91 69 00 lds r25, 0x0069 + 234: 89 3c cpi r24, 0xC9 ; 201 + 236: 92 43 sbci r25, 0x32 ; 50 + 238: 50 f0 brcs .+20 ; 0x24e + 23a: 10 92 60 00 sts 0x0060, r1 + 23e: 80 91 61 00 lds r24, 0x0061 + 242: 82 30 cpi r24, 0x02 ; 2 + 244: 68 f4 brcc .+26 ; 0x260 + 246: 8f 5f subi r24, 0xFF ; 255 + 248: 80 93 61 00 sts 0x0061, r24 + 24c: 09 c0 rjmp .+18 ; 0x260 + 24e: 10 92 61 00 sts 0x0061, r1 + 252: 80 91 60 00 lds r24, 0x0060 + 256: 82 30 cpi r24, 0x02 ; 2 + 258: 18 f4 brcc .+6 ; 0x260 + 25a: 8f 5f subi r24, 0xFF ; 255 + 25c: 80 93 60 00 sts 0x0060, r24 + 260: 80 91 63 00 lds r24, 0x0063 + 264: 85 30 cpi r24, 0x05 ; 5 + 266: 18 f0 brcs .+6 ; 0x26e + 268: 10 92 62 00 sts 0x0062, r1 + 26c: 10 c0 rjmp .+32 ; 0x28e + 26e: 80 91 62 00 lds r24, 0x0062 + 272: 83 30 cpi r24, 0x03 ; 3 + 274: 68 f0 brcs .+26 ; 0x290 + 276: 10 92 63 00 sts 0x0063, r1 + 27a: 80 91 61 00 lds r24, 0x0061 + 27e: 82 30 cpi r24, 0x02 ; 2 + 280: 10 f0 brcs .+4 ; 0x286 + 282: c0 9a sbi 0x18, 0 ; 24 + 284: 08 95 ret + 286: 80 91 60 00 lds r24, 0x0060 + 28a: 82 30 cpi r24, 0x02 ; 2 + 28c: 08 f0 brcs .+2 ; 0x290 + 28e: c0 98 cbi 0x18, 0 ; 24 + 290: 08 95 ret + +00000292 <__vector_6>: + 292: 1f 92 push r1 + 294: 0f 92 push r0 + 296: 0f b6 in r0, 0x3f ; 63 + 298: 0f 92 push r0 + 29a: 11 24 eor r1, r1 + 29c: 2f 93 push r18 + 29e: 3f 93 push r19 + 2a0: 4f 93 push r20 + 2a2: 5f 93 push r21 + 2a4: 6f 93 push r22 + 2a6: 7f 93 push r23 + 2a8: 8f 93 push r24 + 2aa: 9f 93 push r25 + 2ac: 80 91 6c 00 lds r24, 0x006C + 2b0: 90 91 6d 00 lds r25, 0x006D + 2b4: 01 96 adiw r24, 0x01 ; 1 + 2b6: 90 93 6d 00 sts 0x006D, r25 + 2ba: 80 93 6c 00 sts 0x006C, r24 + 2be: 20 91 6c 00 lds r18, 0x006C + 2c2: 30 91 6d 00 lds r19, 0x006D + 2c6: 81 e0 ldi r24, 0x01 ; 1 + 2c8: 90 e0 ldi r25, 0x00 ; 0 + 2ca: 20 36 cpi r18, 0x60 ; 96 + 2cc: 4a ee ldi r20, 0xEA ; 234 + 2ce: 34 07 cpc r19, r20 + 2d0: 10 f4 brcc .+4 ; 0x2d6 <__vector_6+0x44> + 2d2: 80 e0 ldi r24, 0x00 ; 0 + 2d4: 90 e0 ldi r25, 0x00 ; 0 + 2d6: 60 e6 ldi r22, 0x60 ; 96 + 2d8: 7a ee ldi r23, 0xEA ; 234 + 2da: 86 9f mul r24, r22 + 2dc: a0 01 movw r20, r0 + 2de: 87 9f mul r24, r23 + 2e0: 50 0d add r21, r0 + 2e2: 96 9f mul r25, r22 + 2e4: 50 0d add r21, r0 + 2e6: 11 24 eor r1, r1 + 2e8: c9 01 movw r24, r18 + 2ea: 84 1b sub r24, r20 + 2ec: 95 0b sbc r25, r21 + 2ee: 90 93 6d 00 sts 0x006D, r25 + 2f2: 80 93 6c 00 sts 0x006C, r24 + 2f6: 9f 91 pop r25 + 2f8: 8f 91 pop r24 + 2fa: 7f 91 pop r23 + 2fc: 6f 91 pop r22 + 2fe: 5f 91 pop r21 + 300: 4f 91 pop r20 + 302: 3f 91 pop r19 + 304: 2f 91 pop r18 + 306: 0f 90 pop r0 + 308: 0f be out 0x3f, r0 ; 63 + 30a: 0f 90 pop r0 + 30c: 1f 90 pop r1 + 30e: 18 95 reti + +00000310 : + 310: 80 e4 ldi r24, 0x40 ; 64 + 312: 87 b9 out 0x07, r24 ; 7 + 314: 83 e0 ldi r24, 0x03 ; 3 + 316: 86 b9 out 0x06, r24 ; 6 + 318: 37 9a sbi 0x06, 7 ; 6 + 31a: 36 9a sbi 0x06, 6 ; 6 + 31c: 36 99 sbic 0x06, 6 ; 6 + 31e: fe cf rjmp .-4 ; 0x31c + 320: 84 b1 in r24, 0x04 ; 4 + 322: 95 b1 in r25, 0x05 ; 5 + 324: 08 95 ret + +00000326 : + 326: 97 b1 in r25, 0x07 ; 7 + 328: 8f 71 andi r24, 0x1F ; 31 + 32a: 90 7e andi r25, 0xE0 ; 224 + 32c: 89 2b or r24, r25 + 32e: 87 b9 out 0x07, r24 ; 7 + 330: 36 9a sbi 0x06, 6 ; 6 + 332: 36 99 sbic 0x06, 6 ; 6 + 334: fe cf rjmp .-4 ; 0x332 + 336: 24 b1 in r18, 0x04 ; 4 + 338: 35 b1 in r19, 0x05 ; 5 + 33a: c9 01 movw r24, r18 + 33c: 08 95 ret + +0000033e : + 33e: ff 92 push r15 + 340: 0f 93 push r16 + 342: 1f 93 push r17 + 344: cf 93 push r28 + 346: df 93 push r29 + 348: 08 2f mov r16, r24 + 34a: 86 2f mov r24, r22 + 34c: 6c e3 ldi r22, 0x3C ; 60 + 34e: c1 d1 rcall .+898 ; 0x6d2 <__udivmodqi4> + 350: f9 2e mov r15, r25 + 352: 10 e0 ldi r17, 0x00 ; 0 + 354: c0 e0 ldi r28, 0x00 ; 0 + 356: d0 e0 ldi r29, 0x00 ; 0 + 358: 05 c0 rjmp .+10 ; 0x364 + 35a: 80 2f mov r24, r16 + 35c: e4 df rcall .-56 ; 0x326 + 35e: c8 0f add r28, r24 + 360: d9 1f adc r29, r25 + 362: 1f 5f subi r17, 0xFF ; 255 + 364: 1f 11 cpse r17, r15 + 366: f9 cf rjmp .-14 ; 0x35a + 368: 61 2f mov r22, r17 + 36a: ce 01 movw r24, r28 + 36c: 70 e0 ldi r23, 0x00 ; 0 + 36e: bd d1 rcall .+890 ; 0x6ea <__udivmodhi4> + 370: cb 01 movw r24, r22 + 372: df 91 pop r29 + 374: cf 91 pop r28 + 376: 1f 91 pop r17 + 378: 0f 91 pop r16 + 37a: ff 90 pop r15 + 37c: 08 95 ret + +0000037e : + 37e: 81 11 cpse r24, r1 + 380: 01 c0 rjmp .+2 ; 0x384 + 382: 84 e6 ldi r24, 0x64 ; 100 + 384: 90 e0 ldi r25, 0x00 ; 0 + 386: ef e1 ldi r30, 0x1F ; 31 + 388: fe e4 ldi r31, 0x4E ; 78 + 38a: 31 97 sbiw r30, 0x01 ; 1 + 38c: f1 f7 brne .-4 ; 0x38a + 38e: 00 c0 rjmp .+0 ; 0x390 + 390: 00 00 nop + 392: 9f 5f subi r25, 0xFF ; 255 + 394: 98 13 cpse r25, r24 + 396: f7 cf rjmp .-18 ; 0x386 + 398: 08 95 ret + +0000039a : + 39a: ef 92 push r14 + 39c: ff 92 push r15 + 39e: 0f 93 push r16 + 3a0: 1f 93 push r17 + 3a2: cf 93 push r28 + 3a4: df 93 push r29 + 3a6: 8c 01 movw r16, r24 + 3a8: 60 e1 ldi r22, 0x10 ; 16 + 3aa: 77 e2 ldi r23, 0x27 ; 39 + 3ac: 9e d1 rcall .+828 ; 0x6ea <__udivmodhi4> + 3ae: 7c 01 movw r14, r24 + 3b0: 86 2f mov r24, r22 + 3b2: 80 5d subi r24, 0xD0 ; 208 + 3b4: ec d0 rcall .+472 ; 0x58e + 3b6: c8 ee ldi r28, 0xE8 ; 232 + 3b8: d3 e0 ldi r29, 0x03 ; 3 + 3ba: c7 01 movw r24, r14 + 3bc: be 01 movw r22, r28 + 3be: 95 d1 rcall .+810 ; 0x6ea <__udivmodhi4> + 3c0: 86 2f mov r24, r22 + 3c2: 80 5d subi r24, 0xD0 ; 208 + 3c4: e4 d0 rcall .+456 ; 0x58e + 3c6: 8e e2 ldi r24, 0x2E ; 46 + 3c8: e2 d0 rcall .+452 ; 0x58e + 3ca: c8 01 movw r24, r16 + 3cc: be 01 movw r22, r28 + 3ce: 8d d1 rcall .+794 ; 0x6ea <__udivmodhi4> + 3d0: 64 e6 ldi r22, 0x64 ; 100 + 3d2: 70 e0 ldi r23, 0x00 ; 0 + 3d4: 8a d1 rcall .+788 ; 0x6ea <__udivmodhi4> + 3d6: 86 2f mov r24, r22 + 3d8: 80 5d subi r24, 0xD0 ; 208 + 3da: df 91 pop r29 + 3dc: cf 91 pop r28 + 3de: 1f 91 pop r17 + 3e0: 0f 91 pop r16 + 3e2: ff 90 pop r15 + 3e4: ef 90 pop r14 + 3e6: d3 c0 rjmp .+422 ; 0x58e + +000003e8 : + 3e8: 0f 93 push r16 + 3ea: 1f 93 push r17 + 3ec: cf 93 push r28 + 3ee: df 93 push r29 + 3f0: 1f 92 push r1 + 3f2: cd b7 in r28, 0x3d ; 61 + 3f4: de b7 in r29, 0x3e ; 62 + 3f6: 08 2f mov r16, r24 + 3f8: 64 e6 ldi r22, 0x64 ; 100 + 3fa: 6b d1 rcall .+726 ; 0x6d2 <__udivmodqi4> + 3fc: 80 5d subi r24, 0xD0 ; 208 + 3fe: 99 83 std Y+1, r25 ; 0x01 + 400: c6 d0 rcall .+396 ; 0x58e + 402: 1a e0 ldi r17, 0x0A ; 10 + 404: 99 81 ldd r25, Y+1 ; 0x01 + 406: 89 2f mov r24, r25 + 408: 61 2f mov r22, r17 + 40a: 63 d1 rcall .+710 ; 0x6d2 <__udivmodqi4> + 40c: 80 5d subi r24, 0xD0 ; 208 + 40e: bf d0 rcall .+382 ; 0x58e + 410: 80 2f mov r24, r16 + 412: 61 2f mov r22, r17 + 414: 5e d1 rcall .+700 ; 0x6d2 <__udivmodqi4> + 416: 89 2f mov r24, r25 + 418: 80 5d subi r24, 0xD0 ; 208 + 41a: 0f 90 pop r0 + 41c: df 91 pop r29 + 41e: cf 91 pop r28 + 420: 1f 91 pop r17 + 422: 0f 91 pop r16 + 424: b4 c0 rjmp .+360 ; 0x58e + +00000426 : + 426: ef 92 push r14 + 428: ff 92 push r15 + 42a: 0f 93 push r16 + 42c: 1f 93 push r17 + 42e: cf 93 push r28 + 430: df 93 push r29 + 432: ec 01 movw r28, r24 + 434: 60 e1 ldi r22, 0x10 ; 16 + 436: 77 e2 ldi r23, 0x27 ; 39 + 438: 58 d1 rcall .+688 ; 0x6ea <__udivmodhi4> + 43a: 7c 01 movw r14, r24 + 43c: 86 2f mov r24, r22 + 43e: 80 5d subi r24, 0xD0 ; 208 + 440: a6 d0 rcall .+332 ; 0x58e + 442: 08 ee ldi r16, 0xE8 ; 232 + 444: 13 e0 ldi r17, 0x03 ; 3 + 446: c7 01 movw r24, r14 + 448: b8 01 movw r22, r16 + 44a: 4f d1 rcall .+670 ; 0x6ea <__udivmodhi4> + 44c: 86 2f mov r24, r22 + 44e: 80 5d subi r24, 0xD0 ; 208 + 450: 9e d0 rcall .+316 ; 0x58e + 452: ce 01 movw r24, r28 + 454: b8 01 movw r22, r16 + 456: 49 d1 rcall .+658 ; 0x6ea <__udivmodhi4> + 458: 04 e6 ldi r16, 0x64 ; 100 + 45a: 10 e0 ldi r17, 0x00 ; 0 + 45c: b8 01 movw r22, r16 + 45e: 45 d1 rcall .+650 ; 0x6ea <__udivmodhi4> + 460: 86 2f mov r24, r22 + 462: 80 5d subi r24, 0xD0 ; 208 + 464: 94 d0 rcall .+296 ; 0x58e + 466: ce 01 movw r24, r28 + 468: b8 01 movw r22, r16 + 46a: 3f d1 rcall .+638 ; 0x6ea <__udivmodhi4> + 46c: 0a e0 ldi r16, 0x0A ; 10 + 46e: 10 e0 ldi r17, 0x00 ; 0 + 470: b8 01 movw r22, r16 + 472: 3b d1 rcall .+630 ; 0x6ea <__udivmodhi4> + 474: 86 2f mov r24, r22 + 476: 80 5d subi r24, 0xD0 ; 208 + 478: 8a d0 rcall .+276 ; 0x58e + 47a: ce 01 movw r24, r28 + 47c: b8 01 movw r22, r16 + 47e: 35 d1 rcall .+618 ; 0x6ea <__udivmodhi4> + 480: 80 5d subi r24, 0xD0 ; 208 + 482: df 91 pop r29 + 484: cf 91 pop r28 + 486: 1f 91 pop r17 + 488: 0f 91 pop r16 + 48a: ff 90 pop r15 + 48c: ef 90 pop r14 + 48e: 7f c0 rjmp .+254 ; 0x58e + +00000490 <__vector_11>: + 490: 1f 92 push r1 + 492: 0f 92 push r0 + 494: 0f b6 in r0, 0x3f ; 63 + 496: 0f 92 push r0 + 498: 11 24 eor r1, r1 + 49a: 2f 93 push r18 + 49c: 8f 93 push r24 + 49e: 9f 93 push r25 + 4a0: ef 93 push r30 + 4a2: ff 93 push r31 + 4a4: 8b b1 in r24, 0x0b ; 11 + 4a6: 9c b1 in r25, 0x0c ; 12 + 4a8: 88 71 andi r24, 0x18 ; 24 + 4aa: e0 91 72 00 lds r30, 0x0072 + 4ae: ef 5f subi r30, 0xFF ; 255 + 4b0: ef 71 andi r30, 0x1F ; 31 + 4b2: 20 91 71 00 lds r18, 0x0071 + 4b6: e2 17 cp r30, r18 + 4b8: 39 f0 breq .+14 ; 0x4c8 <__vector_11+0x38> + 4ba: e0 93 72 00 sts 0x0072, r30 + 4be: f0 e0 ldi r31, 0x00 ; 0 + 4c0: eb 58 subi r30, 0x8B ; 139 + 4c2: ff 4f sbci r31, 0xFF ; 255 + 4c4: 90 83 st Z, r25 + 4c6: 01 c0 rjmp .+2 ; 0x4ca <__vector_11+0x3a> + 4c8: 82 e0 ldi r24, 0x02 ; 2 + 4ca: 90 91 70 00 lds r25, 0x0070 + 4ce: 98 2b or r25, r24 + 4d0: 90 93 70 00 sts 0x0070, r25 + 4d4: ff 91 pop r31 + 4d6: ef 91 pop r30 + 4d8: 9f 91 pop r25 + 4da: 8f 91 pop r24 + 4dc: 2f 91 pop r18 + 4de: 0f 90 pop r0 + 4e0: 0f be out 0x3f, r0 ; 63 + 4e2: 0f 90 pop r0 + 4e4: 1f 90 pop r1 + 4e6: 18 95 reti + +000004e8 <__vector_12>: + 4e8: 1f 92 push r1 + 4ea: 0f 92 push r0 + 4ec: 0f b6 in r0, 0x3f ; 63 + 4ee: 0f 92 push r0 + 4f0: 11 24 eor r1, r1 + 4f2: 8f 93 push r24 + 4f4: 9f 93 push r25 + 4f6: ef 93 push r30 + 4f8: ff 93 push r31 + 4fa: 90 91 74 00 lds r25, 0x0074 + 4fe: 80 91 73 00 lds r24, 0x0073 + 502: 98 17 cp r25, r24 + 504: 61 f0 breq .+24 ; 0x51e <__vector_12+0x36> + 506: e0 91 73 00 lds r30, 0x0073 + 50a: ef 5f subi r30, 0xFF ; 255 + 50c: ef 71 andi r30, 0x1F ; 31 + 50e: e0 93 73 00 sts 0x0073, r30 + 512: f0 e0 ldi r31, 0x00 ; 0 + 514: eb 56 subi r30, 0x6B ; 107 + 516: ff 4f sbci r31, 0xFF ; 255 + 518: 80 81 ld r24, Z + 51a: 8c b9 out 0x0c, r24 ; 12 + 51c: 01 c0 rjmp .+2 ; 0x520 <__vector_12+0x38> + 51e: 55 98 cbi 0x0a, 5 ; 10 + 520: ff 91 pop r31 + 522: ef 91 pop r30 + 524: 9f 91 pop r25 + 526: 8f 91 pop r24 + 528: 0f 90 pop r0 + 52a: 0f be out 0x3f, r0 ; 63 + 52c: 0f 90 pop r0 + 52e: 1f 90 pop r1 + 530: 18 95 reti + +00000532 : + 532: 10 92 74 00 sts 0x0074, r1 + 536: 10 92 73 00 sts 0x0073, r1 + 53a: 10 92 72 00 sts 0x0072, r1 + 53e: 10 92 71 00 sts 0x0071, r1 + 542: 97 ff sbrs r25, 7 + 544: 03 c0 rjmp .+6 ; 0x54c + 546: 22 e0 ldi r18, 0x02 ; 2 + 548: 2b b9 out 0x0b, r18 ; 11 + 54a: 9f 77 andi r25, 0x7F ; 127 + 54c: 90 bd out 0x20, r25 ; 32 + 54e: 89 b9 out 0x09, r24 ; 9 + 550: 88 e9 ldi r24, 0x98 ; 152 + 552: 8a b9 out 0x0a, r24 ; 10 + 554: 86 e8 ldi r24, 0x86 ; 134 + 556: 80 bd out 0x20, r24 ; 32 + 558: 08 95 ret + +0000055a : + 55a: 90 91 72 00 lds r25, 0x0072 + 55e: 80 91 71 00 lds r24, 0x0071 + 562: 98 17 cp r25, r24 + 564: 81 f0 breq .+32 ; 0x586 + 566: e0 91 71 00 lds r30, 0x0071 + 56a: ef 5f subi r30, 0xFF ; 255 + 56c: ef 71 andi r30, 0x1F ; 31 + 56e: e0 93 71 00 sts 0x0071, r30 + 572: f0 e0 ldi r31, 0x00 ; 0 + 574: eb 58 subi r30, 0x8B ; 139 + 576: ff 4f sbci r31, 0xFF ; 255 + 578: 20 81 ld r18, Z + 57a: 80 91 70 00 lds r24, 0x0070 + 57e: 10 92 70 00 sts 0x0070, r1 + 582: 30 e0 ldi r19, 0x00 ; 0 + 584: 02 c0 rjmp .+4 ; 0x58a + 586: 20 e0 ldi r18, 0x00 ; 0 + 588: 31 e0 ldi r19, 0x01 ; 1 + 58a: c9 01 movw r24, r18 + 58c: 08 95 ret + +0000058e : + 58e: 90 91 74 00 lds r25, 0x0074 + 592: 9f 5f subi r25, 0xFF ; 255 + 594: 9f 71 andi r25, 0x1F ; 31 + 596: 20 91 73 00 lds r18, 0x0073 + 59a: 92 17 cp r25, r18 + 59c: e1 f3 breq .-8 ; 0x596 + 59e: e9 2f mov r30, r25 + 5a0: f0 e0 ldi r31, 0x00 ; 0 + 5a2: eb 56 subi r30, 0x6B ; 107 + 5a4: ff 4f sbci r31, 0xFF ; 255 + 5a6: 80 83 st Z, r24 + 5a8: 90 93 74 00 sts 0x0074, r25 + 5ac: 55 9a sbi 0x0a, 5 ; 10 + 5ae: 08 95 ret + +000005b0 : + 5b0: cf 93 push r28 + 5b2: df 93 push r29 + 5b4: ec 01 movw r28, r24 + 5b6: 01 c0 rjmp .+2 ; 0x5ba + 5b8: ea df rcall .-44 ; 0x58e + 5ba: 89 91 ld r24, Y+ + 5bc: 81 11 cpse r24, r1 + 5be: fc cf rjmp .-8 ; 0x5b8 + 5c0: df 91 pop r29 + 5c2: cf 91 pop r28 + 5c4: 08 95 ret + +000005c6 : + 5c6: cf 93 push r28 + 5c8: df 93 push r29 + 5ca: ec 01 movw r28, r24 + 5cc: 01 c0 rjmp .+2 ; 0x5d0 + 5ce: df df rcall .-66 ; 0x58e + 5d0: fe 01 movw r30, r28 + 5d2: 21 96 adiw r28, 0x01 ; 1 + 5d4: 84 91 lpm r24, Z+ + 5d6: 81 11 cpse r24, r1 + 5d8: fa cf rjmp .-12 ; 0x5ce + 5da: df 91 pop r29 + 5dc: cf 91 pop r28 + 5de: 08 95 ret + +000005e0
: + 5e0: 87 b3 in r24, 0x17 ; 23 + 5e2: 83 60 ori r24, 0x03 ; 3 + 5e4: 87 bb out 0x17, r24 ; 23 + 5e6: 88 b3 in r24, 0x18 ; 24 + 5e8: 8c 7f andi r24, 0xFC ; 252 + 5ea: 88 bb out 0x18, r24 ; 24 + 5ec: 91 de rcall .-734 ; 0x310 + 5ee: 8e b5 in r24, 0x2e ; 46 + 5f0: 8b 60 ori r24, 0x0B ; 11 + 5f2: 8e bd out 0x2e, r24 ; 46 + 5f4: 82 ee ldi r24, 0xE2 ; 226 + 5f6: 94 e0 ldi r25, 0x04 ; 4 + 5f8: 9b bd out 0x2b, r25 ; 43 + 5fa: 8a bd out 0x2a, r24 ; 42 + 5fc: 80 e1 ldi r24, 0x10 ; 16 + 5fe: 89 bf out 0x39, r24 ; 57 + 600: 78 94 sei + 602: 89 e1 ldi r24, 0x19 ; 25 + 604: 90 e0 ldi r25, 0x00 ; 0 + 606: 95 df rcall .-214 ; 0x532 + 608: c0 98 cbi 0x18, 0 ; 24 + 60a: c1 9a sbi 0x18, 1 ; 24 + 60c: c4 e6 ldi r28, 0x64 ; 100 + 60e: d0 e0 ldi r29, 0x00 ; 0 + 610: 80 91 6c 00 lds r24, 0x006C + 614: 90 91 6d 00 lds r25, 0x006D + 618: 84 36 cpi r24, 0x64 ; 100 + 61a: 91 05 cpc r25, r1 + 61c: 30 f0 brcs .+12 ; 0x62a + 61e: 10 92 6d 00 sts 0x006D, r1 + 622: 10 92 6c 00 sts 0x006C, r1 + 626: 42 dd rcall .-1404 ; 0xac + 628: e7 dd rcall .-1074 ; 0x1f8 + 62a: 97 df rcall .-210 ; 0x55a + 62c: 81 15 cp r24, r1 + 62e: 21 e0 ldi r18, 0x01 ; 1 + 630: 92 07 cpc r25, r18 + 632: 71 f3 breq .-36 ; 0x610 + 634: 99 27 eor r25, r25 + 636: 81 36 cpi r24, 0x61 ; 97 + 638: 91 05 cpc r25, r1 + 63a: 29 f0 breq .+10 ; 0x646 + 63c: 80 37 cpi r24, 0x70 ; 112 + 63e: 91 05 cpc r25, r1 + 640: 39 f7 brne .-50 ; 0x610 + 642: 8b dd rcall .-1258 ; 0x15a + 644: e5 cf rjmp .-54 ; 0x610 + 646: 81 e4 ldi r24, 0x41 ; 65 + 648: a2 df rcall .-188 ; 0x58e + 64a: 80 91 6a 00 lds r24, 0x006A + 64e: 90 91 6b 00 lds r25, 0x006B + 652: e9 de rcall .-558 ; 0x426 + 654: 8c e2 ldi r24, 0x2C ; 44 + 656: 9b df rcall .-202 ; 0x58e + 658: 80 91 66 00 lds r24, 0x0066 + 65c: 90 91 67 00 lds r25, 0x0067 + 660: e2 de rcall .-572 ; 0x426 + 662: 8c e2 ldi r24, 0x2C ; 44 + 664: 94 df rcall .-216 ; 0x58e + 666: 80 e0 ldi r24, 0x00 ; 0 + 668: 90 e0 ldi r25, 0x00 ; 0 + 66a: dd de rcall .-582 ; 0x426 + 66c: 8c e2 ldi r24, 0x2C ; 44 + 66e: 8f df rcall .-226 ; 0x58e + 670: 80 91 66 00 lds r24, 0x0066 + 674: 90 91 67 00 lds r25, 0x0067 + 678: be 01 movw r22, r28 + 67a: 4b d0 rcall .+150 ; 0x712 <__divmodhi4> + 67c: 9b 01 movw r18, r22 + 67e: 80 91 6a 00 lds r24, 0x006A + 682: 90 91 6b 00 lds r25, 0x006B + 686: be 01 movw r22, r28 + 688: 30 d0 rcall .+96 ; 0x6ea <__udivmodhi4> + 68a: 26 9f mul r18, r22 + 68c: c0 01 movw r24, r0 + 68e: 27 9f mul r18, r23 + 690: 90 0d add r25, r0 + 692: 36 9f mul r19, r22 + 694: 90 0d add r25, r0 + 696: 11 24 eor r1, r1 + 698: be 01 movw r22, r28 + 69a: 27 d0 rcall .+78 ; 0x6ea <__udivmodhi4> + 69c: cb 01 movw r24, r22 + 69e: c3 de rcall .-634 ; 0x426 + 6a0: 8c e2 ldi r24, 0x2C ; 44 + 6a2: 75 df rcall .-278 ; 0x58e + 6a4: 80 e0 ldi r24, 0x00 ; 0 + 6a6: 90 e0 ldi r25, 0x00 ; 0 + 6a8: be de rcall .-644 ; 0x426 + 6aa: 8c e2 ldi r24, 0x2C ; 44 + 6ac: 70 df rcall .-288 ; 0x58e + 6ae: 86 b3 in r24, 0x16 ; 22 + 6b0: 81 70 andi r24, 0x01 ; 1 + 6b2: 80 5d subi r24, 0xD0 ; 208 + 6b4: 6c df rcall .-296 ; 0x58e + 6b6: 8c e2 ldi r24, 0x2C ; 44 + 6b8: 6a df rcall .-300 ; 0x58e + 6ba: 80 e3 ldi r24, 0x30 ; 48 + 6bc: 68 df rcall .-304 ; 0x58e + 6be: 8c e2 ldi r24, 0x2C ; 44 + 6c0: 66 df rcall .-308 ; 0x58e + 6c2: 86 b3 in r24, 0x16 ; 22 + 6c4: 86 95 lsr r24 + 6c6: 81 70 andi r24, 0x01 ; 1 + 6c8: 80 5d subi r24, 0xD0 ; 208 + 6ca: 61 df rcall .-318 ; 0x58e + 6cc: 82 e4 ldi r24, 0x42 ; 66 + 6ce: 5f df rcall .-322 ; 0x58e + 6d0: 9f cf rjmp .-194 ; 0x610 + +000006d2 <__udivmodqi4>: + 6d2: 99 1b sub r25, r25 + 6d4: 79 e0 ldi r23, 0x09 ; 9 + 6d6: 04 c0 rjmp .+8 ; 0x6e0 <__udivmodqi4_ep> + +000006d8 <__udivmodqi4_loop>: + 6d8: 99 1f adc r25, r25 + 6da: 96 17 cp r25, r22 + 6dc: 08 f0 brcs .+2 ; 0x6e0 <__udivmodqi4_ep> + 6de: 96 1b sub r25, r22 + +000006e0 <__udivmodqi4_ep>: + 6e0: 88 1f adc r24, r24 + 6e2: 7a 95 dec r23 + 6e4: c9 f7 brne .-14 ; 0x6d8 <__udivmodqi4_loop> + 6e6: 80 95 com r24 + 6e8: 08 95 ret + +000006ea <__udivmodhi4>: + 6ea: aa 1b sub r26, r26 + 6ec: bb 1b sub r27, r27 + 6ee: 51 e1 ldi r21, 0x11 ; 17 + 6f0: 07 c0 rjmp .+14 ; 0x700 <__udivmodhi4_ep> + +000006f2 <__udivmodhi4_loop>: + 6f2: aa 1f adc r26, r26 + 6f4: bb 1f adc r27, r27 + 6f6: a6 17 cp r26, r22 + 6f8: b7 07 cpc r27, r23 + 6fa: 10 f0 brcs .+4 ; 0x700 <__udivmodhi4_ep> + 6fc: a6 1b sub r26, r22 + 6fe: b7 0b sbc r27, r23 + +00000700 <__udivmodhi4_ep>: + 700: 88 1f adc r24, r24 + 702: 99 1f adc r25, r25 + 704: 5a 95 dec r21 + 706: a9 f7 brne .-22 ; 0x6f2 <__udivmodhi4_loop> + 708: 80 95 com r24 + 70a: 90 95 com r25 + 70c: bc 01 movw r22, r24 + 70e: cd 01 movw r24, r26 + 710: 08 95 ret + +00000712 <__divmodhi4>: + 712: 97 fb bst r25, 7 + 714: 07 2e mov r0, r23 + 716: 16 f4 brtc .+4 ; 0x71c <__divmodhi4+0xa> + 718: 00 94 com r0 + 71a: 06 d0 rcall .+12 ; 0x728 <__divmodhi4_neg1> + 71c: 77 fd sbrc r23, 7 + 71e: 08 d0 rcall .+16 ; 0x730 <__divmodhi4_neg2> + 720: e4 df rcall .-56 ; 0x6ea <__udivmodhi4> + 722: 07 fc sbrc r0, 7 + 724: 05 d0 rcall .+10 ; 0x730 <__divmodhi4_neg2> + 726: 3e f4 brtc .+14 ; 0x736 <__divmodhi4_exit> + +00000728 <__divmodhi4_neg1>: + 728: 90 95 com r25 + 72a: 81 95 neg r24 + 72c: 9f 4f sbci r25, 0xFF ; 255 + 72e: 08 95 ret + +00000730 <__divmodhi4_neg2>: + 730: 70 95 com r23 + 732: 61 95 neg r22 + 734: 7f 4f sbci r23, 0xFF ; 255 + +00000736 <__divmodhi4_exit>: + 736: 08 95 ret + +00000738 <_exit>: + 738: f8 94 cli + +0000073a <__stop_program>: + 73a: ff cf rjmp .-2 ; 0x73a <__stop_program> diff --git a/display_v2/software/powerboard_v2/main.map b/display_v2/software/powerboard_v2/main.map new file mode 100644 index 0000000..b0eccc4 --- /dev/null +++ b/display_v2/software/powerboard_v2/main.map @@ -0,0 +1,543 @@ +Archive member included because of file (symbol) + +/usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + src/adc.o (__udivmodqi4) +/usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + src/main.o (__udivmodhi4) +/usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + src/main.o (__divmodhi4) +/usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o (exit) +/usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + src/main.o (__do_clear_bss) + +Memory Configuration + +Name Origin Length Attributes +text 0x0000000000000000 0x0000000000002000 xr +data 0x0000000000800060 0x000000000000ffa0 rw !x +eeprom 0x0000000000810000 0x0000000000010000 rw !x +fuse 0x0000000000820000 0x0000000000000400 rw !x +lock 0x0000000000830000 0x0000000000000400 rw !x +signature 0x0000000000840000 0x0000000000000400 rw !x +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +LOAD /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +LOAD src/main.o +LOAD src/adc.o +LOAD src/utils.o +LOAD src/uart.o +LOAD /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a +LOAD /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/libc.a +LOAD /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a + +.hash + *(.hash) + +.dynsym + *(.dynsym) + +.dynstr + *(.dynstr) + +.gnu.version + *(.gnu.version) + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r + *(.gnu.version_r) + +.rel.init + *(.rel.init) + +.rela.init + *(.rela.init) + +.rel.text + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t*) + +.rela.text + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t*) + +.rel.fini + *(.rel.fini) + +.rela.fini + *(.rela.fini) + +.rel.rodata + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r*) + +.rela.rodata + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r*) + +.rel.data + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d*) + +.rela.data + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d*) + +.rel.ctors + *(.rel.ctors) + +.rela.ctors + *(.rela.ctors) + +.rel.dtors + *(.rel.dtors) + +.rela.dtors + *(.rela.dtors) + +.rel.got + *(.rel.got) + +.rela.got + *(.rela.got) + +.rel.bss + *(.rel.bss) + +.rela.bss + *(.rela.bss) + +.rel.plt + *(.rel.plt) + +.rela.plt + *(.rela.plt) + +.text 0x0000000000000000 0x73a + *(.vectors) + .vectors 0x0000000000000000 0x26 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + 0x0000000000000000 __vectors + 0x0000000000000000 __vector_default + *(.vectors) + *(.progmem.gcc*) + *(.progmem*) + .progmem.data 0x0000000000000026 0x63 src/main.o + 0x000000000000008a . = ALIGN (0x2) + *fill* 0x0000000000000089 0x1 00 + 0x000000000000008a __trampolines_start = . + *(.trampolines) + .trampolines 0x000000000000008a 0x0 linker stubs + *(.trampolines*) + 0x000000000000008a __trampolines_end = . + *(.jumptables) + *(.jumptables*) + *(.lowtext) + *(.lowtext*) + 0x000000000000008a __ctors_start = . + *(.ctors) + 0x000000000000008a __ctors_end = . + 0x000000000000008a __dtors_start = . + *(.dtors) + 0x000000000000008a __dtors_end = . + SORT(*)(.ctors) + SORT(*)(.dtors) + *(.init0) + .init0 0x000000000000008a 0x0 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + 0x000000000000008a __init + *(.init0) + *(.init1) + *(.init1) + *(.init2) + .init2 0x000000000000008a 0xc /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + *(.init2) + *(.init3) + *(.init3) + *(.init4) + .init4 0x0000000000000096 0x10 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + 0x0000000000000096 __do_clear_bss + *(.init4) + *(.init5) + *(.init5) + *(.init6) + *(.init6) + *(.init7) + *(.init7) + *(.init8) + *(.init8) + *(.init9) + .init9 0x00000000000000a6 0x4 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + *(.init9) + *(.text) + .text 0x00000000000000aa 0x2 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + 0x00000000000000aa __vector_1 + 0x00000000000000aa __bad_interrupt + 0x00000000000000aa __vector_3 + 0x00000000000000aa __vector_13 + 0x00000000000000aa __vector_17 + 0x00000000000000aa __vector_7 + 0x00000000000000aa __vector_5 + 0x00000000000000aa __vector_4 + 0x00000000000000aa __vector_9 + 0x00000000000000aa __vector_2 + 0x00000000000000aa __vector_15 + 0x00000000000000aa __vector_8 + 0x00000000000000aa __vector_14 + 0x00000000000000aa __vector_10 + 0x00000000000000aa __vector_16 + 0x00000000000000aa __vector_18 + .text 0x00000000000000ac 0x262 src/main.o + 0x00000000000000ac measure + 0x0000000000000128 get_power + 0x000000000000015a pretty_print_all_values + 0x00000000000001f8 handle_over_and_undervoltage + 0x0000000000000290 __vector_6 + .text 0x000000000000030e 0x6e src/adc.o + 0x000000000000030e adc_init + 0x0000000000000324 adc_read_single + 0x000000000000033c adc_read_avg + .text 0x000000000000037c 0x112 src/utils.o + 0x000000000000037c wait + 0x0000000000000398 uart_print_voltage + 0x00000000000003e6 uart_print_uint8 + 0x0000000000000424 uart_print_uint16 + .text 0x000000000000048e 0x150 src/uart.o + 0x000000000000048e __vector_11 + 0x00000000000004e6 __vector_12 + 0x0000000000000530 uart_init + 0x0000000000000558 uart_getc + 0x000000000000058c uart_putc + 0x00000000000005ae uart_puts + 0x00000000000005c4 uart_puts_p + .text 0x00000000000005de 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + .text 0x00000000000005de 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + .text 0x00000000000005de 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + .text 0x00000000000005de 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .text 0x00000000000005de 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + 0x00000000000005de . = ALIGN (0x2) + *(.text.*) + .text.startup 0x00000000000005de 0xf2 src/main.o + 0x00000000000005de main + .text.libgcc.mul + 0x00000000000006d0 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + .text.libgcc.div + 0x00000000000006d0 0x18 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + 0x00000000000006d0 __udivmodqi4 + .text.libgcc 0x00000000000006e8 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + .text.libgcc.prologue + 0x00000000000006e8 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + .text.libgcc.builtins + 0x00000000000006e8 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + .text.libgcc.fmul + 0x00000000000006e8 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + .text.libgcc.mul + 0x00000000000006e8 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + .text.libgcc.div + 0x00000000000006e8 0x28 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + 0x00000000000006e8 __udivmodhi4 + .text.libgcc 0x0000000000000710 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + .text.libgcc.prologue + 0x0000000000000710 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + .text.libgcc.builtins + 0x0000000000000710 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + .text.libgcc.fmul + 0x0000000000000710 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + .text.libgcc.mul + 0x0000000000000710 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + .text.libgcc.div + 0x0000000000000710 0x26 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + 0x0000000000000710 __divmodhi4 + 0x0000000000000710 _div + .text.libgcc 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + .text.libgcc.prologue + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + .text.libgcc.builtins + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + .text.libgcc.fmul + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + .text.libgcc.mul + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .text.libgcc.div + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .text.libgcc 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .text.libgcc.prologue + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .text.libgcc.builtins + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .text.libgcc.fmul + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .text.libgcc.mul + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + .text.libgcc.div + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + .text.libgcc 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + .text.libgcc.prologue + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + .text.libgcc.builtins + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + .text.libgcc.fmul + 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + 0x0000000000000736 . = ALIGN (0x2) + *(.fini9) + .fini9 0x0000000000000736 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + 0x0000000000000736 exit + 0x0000000000000736 _exit + *(.fini9) + *(.fini8) + *(.fini8) + *(.fini7) + *(.fini7) + *(.fini6) + *(.fini6) + *(.fini5) + *(.fini5) + *(.fini4) + *(.fini4) + *(.fini3) + *(.fini3) + *(.fini2) + *(.fini2) + *(.fini1) + *(.fini1) + *(.fini0) + .fini0 0x0000000000000736 0x4 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + *(.fini0) + 0x000000000000073a _etext = . + +.data 0x0000000000800060 0x0 load address 0x000000000000073a + 0x0000000000800060 PROVIDE (__data_start, .) + *(.data) + .data 0x0000000000800060 0x0 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + .data 0x0000000000800060 0x0 src/main.o + .data 0x0000000000800060 0x0 src/adc.o + .data 0x0000000000800060 0x0 src/utils.o + .data 0x0000000000800060 0x0 src/uart.o + .data 0x0000000000800060 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + .data 0x0000000000800060 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + .data 0x0000000000800060 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + .data 0x0000000000800060 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .data 0x0000000000800060 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + *(.data*) + *(.rodata) + *(.rodata*) + *(.gnu.linkonce.d*) + 0x0000000000800060 . = ALIGN (0x2) + 0x0000000000800060 _edata = . + 0x0000000000800060 PROVIDE (__data_end, .) + +.bss 0x0000000000800060 0x55 + 0x0000000000800060 PROVIDE (__bss_start, .) + *(.bss) + .bss 0x0000000000800060 0x0 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + .bss 0x0000000000800060 0x10 src/main.o + 0x0000000000800060 generator_off_counter + 0x0000000000800061 generator_counter + 0x0000000000800062 undervoltage_off_counter + 0x0000000000800063 undervoltage_counter + 0x0000000000800064 overvoltage_off_counter + 0x0000000000800065 overvoltage_counter + 0x0000000000800066 current_in + 0x0000000000800068 voltage_gen + 0x000000000080006a voltage_bat + 0x000000000080006c syscounter + .bss 0x0000000000800070 0x0 src/adc.o + .bss 0x0000000000800070 0x0 src/utils.o + .bss 0x0000000000800070 0x45 src/uart.o + .bss 0x00000000008000b5 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + .bss 0x00000000008000b5 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + .bss 0x00000000008000b5 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + .bss 0x00000000008000b5 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + .bss 0x00000000008000b5 0x0 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + *(.bss*) + *(COMMON) + 0x00000000008000b5 PROVIDE (__bss_end, .) + 0x000000000000073a __data_load_start = LOADADDR (.data) + 0x000000000000073a __data_load_end = (__data_load_start + SIZEOF (.data)) + +.noinit 0x00000000008000b5 0x0 + 0x00000000008000b5 PROVIDE (__noinit_start, .) + *(.noinit*) + 0x00000000008000b5 PROVIDE (__noinit_end, .) + 0x00000000008000b5 _end = . + 0x00000000008000b5 PROVIDE (__heap_start, .) + +.eeprom 0x0000000000810000 0x0 + *(.eeprom*) + 0x0000000000810000 __eeprom_end = . + +.fuse + *(.fuse) + *(.lfuse) + *(.hfuse) + *(.efuse) + +.lock + *(.lock*) + +.signature + *(.signature*) + +.stab 0x0000000000000000 0x6cc + *(.stab) + .stab 0x0000000000000000 0x6cc /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + +.stabstr 0x0000000000000000 0x54 + *(.stabstr) + .stabstr 0x0000000000000000 0x54 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x11 + *(.comment) + .comment 0x0000000000000000 0x11 src/main.o + 0x12 (size before relaxing) + .comment 0x0000000000000000 0x12 src/adc.o + .comment 0x0000000000000000 0x12 src/utils.o + .comment 0x0000000000000000 0x12 src/uart.o + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges + *(.debug_aranges) + +.debug_pubnames + *(.debug_pubnames) + +.debug_info + *(.debug_info) + *(.gnu.linkonce.wi.*) + +.debug_abbrev + *(.debug_abbrev) + +.debug_line + *(.debug_line) + +.debug_frame + *(.debug_frame) + +.debug_str + *(.debug_str) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) +OUTPUT(main.elf elf32-avr) +LOAD linker stubs + +Cross Reference Table + +Symbol File +__bad_interrupt /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__bss_end /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) +__bss_start /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) +__divmodhi4 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + src/main.o +__do_clear_bss /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_clear_bss.o) + src/uart.o + src/main.o +__heap_end /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__init /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__stack /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__udivmodhi4 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodhi4.o) + /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) + src/utils.o + src/adc.o + src/main.o +__udivmodqi4 /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_udivmodqi4.o) + src/utils.o + src/adc.o +__vector_1 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_10 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_11 src/uart.o + /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_12 src/uart.o + /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_13 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_14 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_15 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_16 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_17 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_18 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_2 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_3 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_4 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_5 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_6 src/main.o + /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_7 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_8 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_9 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vector_default /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +__vectors /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +_div /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_divmodhi4.o) +_exit /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) +adc_init src/adc.o + src/main.o +adc_read_avg src/adc.o + src/main.o +adc_read_single src/adc.o +current_in src/main.o +exit /usr/lib/gcc/avr/4.7.2/avr4/libgcc.a(_exit.o) + /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +generator_counter src/main.o +generator_off_counter src/main.o +get_power src/main.o +handle_over_and_undervoltage src/main.o +main src/main.o + /usr/lib/gcc/avr/4.7.2/../../../avr/lib/avr4/crtm8.o +measure src/main.o +overvoltage_counter src/main.o +overvoltage_off_counter src/main.o +pretty_print_all_values src/main.o +syscounter src/main.o +uart_getc src/uart.o + src/main.o +uart_init src/uart.o + src/main.o +uart_print_uint16 src/utils.o + src/main.o +uart_print_uint8 src/utils.o +uart_print_voltage src/utils.o +uart_putc src/uart.o + src/utils.o + src/main.o +uart_puts src/uart.o +uart_puts_p src/uart.o + src/main.o +undervoltage_counter src/main.o +undervoltage_off_counter src/main.o +voltage_bat src/main.o +voltage_gen src/main.o +wait src/utils.o diff --git a/display_v2/software/powerboard_v2/main.sym b/display_v2/software/powerboard_v2/main.sym new file mode 100644 index 0000000..3b6dd22 --- /dev/null +++ b/display_v2/software/powerboard_v2/main.sym @@ -0,0 +1,119 @@ +00000000 W __heap_end +00000000 a __tmp_reg__ +00000000 a __tmp_reg__ +00000000 a __tmp_reg__ +00000000 a __tmp_reg__ +00000000 W __vector_default +00000000 T __vectors +00000001 a __zero_reg__ +00000001 a __zero_reg__ +00000001 a __zero_reg__ +00000001 a __zero_reg__ +00000026 t __c.1594 +0000003a t __c.1596 +0000003d a __SP_L__ +0000003d a __SP_L__ +0000003d a __SP_L__ +0000003d a __SP_L__ +0000003e a __SP_H__ +0000003e a __SP_H__ +0000003e a __SP_H__ +0000003e a __SP_H__ +0000003f a __SREG__ +0000003f a __SREG__ +0000003f a __SREG__ +0000003f a __SREG__ +0000003f t __c.1598 +00000055 t __c.1600 +0000005a t __c.1602 +00000066 t __c.1604 +0000006b t __c.1606 +0000006f t __c.1608 +00000086 t __c.1610 +0000008a T __ctors_end +0000008a T __ctors_start +0000008a T __dtors_end +0000008a T __dtors_start +0000008a W __init +0000008a T __trampolines_end +0000008a T __trampolines_start +00000096 T __do_clear_bss +0000009e t .do_clear_bss_loop +000000a0 t .do_clear_bss_start +000000aa T __bad_interrupt +000000aa W __vector_1 +000000aa W __vector_10 +000000aa W __vector_13 +000000aa W __vector_14 +000000aa W __vector_15 +000000aa W __vector_16 +000000aa W __vector_17 +000000aa W __vector_18 +000000aa W __vector_2 +000000aa W __vector_3 +000000aa W __vector_4 +000000aa W __vector_5 +000000aa W __vector_7 +000000aa W __vector_8 +000000aa W __vector_9 +000000ac T measure +00000128 T get_power +0000015a T pretty_print_all_values +000001f8 T handle_over_and_undervoltage +00000292 T __vector_6 +00000310 T adc_init +00000326 T adc_read_single +0000033e T adc_read_avg +0000037e T wait +0000039a T uart_print_voltage +000003e8 T uart_print_uint8 +00000426 T uart_print_uint16 +0000045f W __stack +00000490 T __vector_11 +000004e8 T __vector_12 +00000532 T uart_init +0000055a T uart_getc +0000058e T uart_putc +000005b0 T uart_puts +000005c6 T uart_puts_p +000005e0 T main +000006d2 T __udivmodqi4 +000006d8 t __udivmodqi4_loop +000006e0 t __udivmodqi4_ep +000006ea T __udivmodhi4 +000006f2 t __udivmodhi4_loop +00000700 t __udivmodhi4_ep +00000712 T __divmodhi4 +00000712 T _div +00000728 t __divmodhi4_neg1 +00000730 t __divmodhi4_neg2 +00000736 t __divmodhi4_exit +00000738 T _exit +00000738 W exit +0000073a t __stop_program +0000073c A __data_load_end +0000073c A __data_load_start +0000073c T _etext +00800060 B __bss_start +00800060 T _edata +00800060 B generator_off_counter +00800061 B generator_counter +00800062 B undervoltage_off_counter +00800063 B undervoltage_counter +00800064 B overvoltage_off_counter +00800065 B overvoltage_counter +00800066 B current_in +00800068 B voltage_gen +0080006a B voltage_bat +0080006c B syscounter +0080006e b temp.1586 +00800070 b UART_LastRxError +00800071 b UART_RxTail +00800072 b UART_RxHead +00800073 b UART_TxTail +00800074 b UART_TxHead +00800075 b UART_RxBuf +00800095 b UART_TxBuf +008000b5 B __bss_end +008000b5 N _end +00810000 N __eeprom_end diff --git a/display_v2/software/powerboard_v2/powerboard_v2.iml b/display_v2/software/powerboard_v2/powerboard_v2.iml new file mode 100644 index 0000000..7694e87 --- /dev/null +++ b/display_v2/software/powerboard_v2/powerboard_v2.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/display_v2/software/powerboard_v2/src/adc.c b/display_v2/software/powerboard_v2/src/adc.c new file mode 100644 index 0000000..8ad8969 --- /dev/null +++ b/display_v2/software/powerboard_v2/src/adc.c @@ -0,0 +1,42 @@ +#include + + +void adc_init(void) { + uint16_t dummyResult; + // AVCC with external capacitor at AREF pin + ADMUX = _BV(REFS0); + + // set frequency prescaler to 8 + ADCSRA = _BV(ADPS1) | _BV(ADPS0); + + // enable ADC + ADCSRA |= _BV(ADEN); + + // make a dummy read out + ADCSRA |= _BV(ADSC); + while (ADCSRA & _BV(ADSC) ) { + } + + // we have to read, otherwise the next result is not available + dummyResult = ADCW; +} + + +uint16_t adc_read_single(uint8_t channel) { + ADMUX = (ADMUX & ~(0x1F)) | (channel & 0x1F); + ADCSRA |= _BV(ADSC); + while (ADCSRA & (1<5gvm#kiNVBYtAGxO%XH@h$93pW)-A!!ON z(ohloL}C-3iwdS_ltyUd$9Cssu+^E_o!*^(N8L@o?Q89~{_C}!=daFgcjD-zf64!( zXzlP#x}~@FTKg?6yOphcr`|7PEa(QkfVvx5>U~Uq({)oHr>>R#qO1ng`>gCY_nLY$ z-3)iMHs$B$W;0Xy+xO38a>k5tk;rH~aXo7p=+$Ffk*sc4EW@)Odt{U>&mv>F(IBH( zb6vaY$w&SNW>CX(7!kGn{;J>%az-b?Q;GOjmFOPyAyLD*Bk@im*l^}nygaMD3WO|-Z2+UGbV+Y+?~%y#B*28 zx?PU=Q@dUh0y|Bo>Ui7&A**CIoNBpZ54E*kM#D!XXWgxp)|}i>tU%CF9IxX0@qafd fIM0LUr*aau0OuNhS3z)o?*qYa0Ut6?V}bn!T@#aH literal 0 HcmV?d00001 diff --git a/display_v2/software/powerboard_v2/src/main.c b/display_v2/software/powerboard_v2/src/main.c new file mode 100644 index 0000000..249a344 --- /dev/null +++ b/display_v2/software/powerboard_v2/src/main.c @@ -0,0 +1,204 @@ +#include +#include +#include +#include "utils.h" +#include "main.h" +#include "adc.h" +#include "uart.h" + +volatile uint16_t syscounter = 0; +uint16_t voltage_bat = 0; +uint16_t voltage_gen = 0; +uint16_t current_in = 0; + +uint8_t overvoltage_counter = 0; +uint8_t overvoltage_off_counter = 0; +uint8_t undervoltage_counter = 0; +uint8_t undervoltage_off_counter = 0; +uint8_t generator_counter = 0; +uint8_t generator_off_counter = 0; + + +static void timer_init(void) { + // clock is 8MHz + TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64 + OCR1A = 1250; // 100Hz + TIMSK = _BV(OCIE1A); + sei(); // enable interrupts +} + +static void ports_init(void) { + DDR_SW |= _BV(LOADSW) | _BV(GENSW); + PORT_SW &= ~(_BV(LOADSW) | _BV(GENSW)); +} + +void measure(void) { + + static int16_t temp; + + voltage_bat = adc_read_avg(AD_V_BAT, 4); + voltage_bat *= VOLTAGE_PER_TICK; + voltage_bat += 790; + + voltage_gen = adc_read_avg(AD_V_GEN, 4); + voltage_gen *= VOLTAGE_PER_TICK; + + temp = adc_read_avg(AD_I_GEN, 4); + temp -= CURRENT_OFFSET; + if(temp < 0) temp = 0; + current_in = temp * CURRENT_PER_TICK; +} + +uint16_t get_power(uint16_t voltage, int16_t currents) { + return (voltage/100 * (currents/100)) / 100 ; +} + +void pretty_print_all_values(void) { + uart_puts_P("Battery Voltage: "); + uart_print_uint16(voltage_bat); + uart_puts_P("mV\r\n"); + + uart_puts_P("Generator Voltage: "); + uart_print_uint16(voltage_gen); + uart_puts_P("mV\r\n"); + + uart_puts_P("Generator: "); + uart_print_uint16(current_in); + uart_puts_P("mA "); + uart_print_uint16(get_power(voltage_bat, current_in)); + uart_puts_P("W\r\n"); + + uart_puts_P("switches (load, gen): "); + uart_putc(48 + (IS_LOAD_ON >> LOADSW)); + uart_putc(','); + uart_putc(48 + (IS_GEN_ON >> GENSW)); + uart_puts_P("\r\n"); +} + +void handle_over_and_undervoltage(void) { + + if(voltage_bat < UNDERVOLTAGE) { + undervoltage_off_counter = 0; + if(undervoltage_counter GENERATOR) { + generator_off_counter = 0; + if(generator_counter= UNDERVOLTAGE_TIMEOUT) { + // spannung zu niedrig => abschalten + undervoltage_off_counter = 0; + LOAD_OFF; + } else { + // spannung ist okay + + // ist die spannung schon lange genug okay? + if(undervoltage_off_counter >= UNDERVOLTAGEOFF_TIMEOUT) { + undervoltage_counter = 0; + + // ja, also schauen ob der generator schon lange genug läuft + if(generator_counter >= GENERATOR_TIMEOUT) { + // ja, also einschalten + LOAD_ON; + } else { + // nein, generator nicht lange genug an + + // ist er vielleicht schon lange aus? + if(generator_off_counter >= GENERATOR_OFF_TIMEOUT) { + // ja, also abschalten, egal ob akku okay + LOAD_OFF; + } + } + } + } + + +#ifdef DEBUG + uart_puts_P("ov1="); + uart_print_uint8(overvoltage_counter1); + uart_puts_P(" ovo1="); + uart_print_uint8 (overvoltage_off_counter1); + uart_puts_P("\r\n"); + + uart_puts_P("uv ="); + uart_print_uint8(undervoltage_counter); + uart_puts_P(" uvo ="); + uart_print_uint8(undervoltage_off_counter); + uart_puts_P("\r\n"); +#endif + +} + +static void work_uart(void) { + uint16_t uart_char = uart_getc(); + + if(uart_char != UART_NO_DATA) { + switch(uart_char & 0xff) { + case 'p': + pretty_print_all_values(); + break; + case 'a': + uart_putc('A'); + uart_print_uint16(voltage_bat); + uart_putc(','); + uart_print_uint16(current_in); + uart_putc(','); + uart_print_uint16(0); + uart_putc(','); + uart_print_uint16(get_power(voltage_bat, current_in)); + uart_putc(','); + uart_print_uint16(0); + uart_putc(','); + uart_putc(48 + (IS_LOAD_ON >> LOADSW)); + uart_putc(','); + uart_putc(48); + uart_putc(','); + uart_putc(48 + (IS_GEN_ON >> GENSW)); + uart_putc('B'); + break; + } + } +} + + +int main(void) { + ports_init(); + adc_init(); + timer_init(); + uart_init(UART_BAUD_SELECT(19200,F_CPU)); + + LOAD_OFF; + GEN_ON; + + while(1) { + if(syscounter >= 100) { + syscounter = 0; + + measure(); + + //pretty_print_all_values(); + + handle_over_and_undervoltage(); + } + + work_uart(); + } + + return(0); +} + +// system timer +SIGNAL(TIMER1_COMPA_vect) { + syscounter++; + syscounter %= 60000; +} + + diff --git a/display_v2/software/powerboard_v2/src/main.h b/display_v2/software/powerboard_v2/src/main.h new file mode 100644 index 0000000..c6d315a --- /dev/null +++ b/display_v2/software/powerboard_v2/src/main.h @@ -0,0 +1,38 @@ +#ifndef _main_h + #define _main_h + + #define AD_V_GEN 0 + #define AD_I_GEN 1 + #define AD_V_BAT 2 + + #define LOADSW PB0 + #define GENSW PB1 + #define PORT_SW PORTB + #define DDR_SW DDRB + #define PIN_SW PINB + + #define LOAD_ON PORT_SW |= _BV(LOADSW) + #define LOAD_OFF PORT_SW &= ~_BV(LOADSW) + #define GEN_ON PORT_SW |= _BV(GENSW) + #define GEN_OFF PORT_SW &= ~_BV(GENSW) + + #define IS_LOAD_ON (PIN_SW & _BV(LOADSW)) + #define IS_GEN_ON (PIN_SW & _BV(GENSW)) + + #define GENERATOR 13000 + #define GENERATOR_TIMEOUT 3 + #define GENERATOR_OFF_TIMEOUT 1 + + #define UNDERVOLTAGE 11200 + #define OVERVOLTAGE 15000 + #define OVERVOLTAGE_TIMEOUT 5 + #define OVERVOLTAGEOFF_TIMEOUT 3 + #define UNDERVOLTAGE_TIMEOUT 5 + #define UNDERVOLTAGEOFF_TIMEOUT 3 + + #define CURRENT_OFFSET 511 + #define CURRENT_PER_TICK 72 + #define VOLTAGE_PER_TICK 15 + +#endif + diff --git a/display_v2/software/powerboard_v2/src/main.lst b/display_v2/software/powerboard_v2/src/main.lst new file mode 100644 index 0000000..f14a6b1 --- /dev/null +++ b/display_v2/software/powerboard_v2/src/main.lst @@ -0,0 +1,544 @@ + 1 .file "main.c" + 2 __SP_H__ = 0x3e + 3 __SP_L__ = 0x3d + 4 __SREG__ = 0x3f + 5 __tmp_reg__ = 0 + 6 __zero_reg__ = 1 + 7 .text + 8 .global measure + 10 measure: + 11 0000 CF93 push r28 + 12 /* prologue: function */ + 13 /* frame size = 0 */ + 14 /* stack size = 1 */ + 15 .L__stack_usage = 1 + 16 0002 64E0 ldi r22,lo8(4) + 17 0004 82E0 ldi r24,lo8(2) + 18 0006 00D0 rcall adc_read_avg + 19 0008 CFE0 ldi r28,lo8(15) + 20 000a 9C01 movw r18,r24 + 21 000c C29F mul r28,r18 + 22 000e C001 movw r24,r0 + 23 0010 C39F mul r28,r19 + 24 0012 900D add r25,r0 + 25 0014 1124 clr __zero_reg__ + 26 0016 8A5E subi r24,-22 + 27 0018 9C4F sbci r25,-4 + 28 001a 9093 0000 sts voltage_bat+1,r25 + 29 001e 8093 0000 sts voltage_bat,r24 + 30 0022 64E0 ldi r22,lo8(4) + 31 0024 80E0 ldi r24,0 + 32 0026 00D0 rcall adc_read_avg + 33 0028 9C01 movw r18,r24 + 34 002a C29F mul r28,r18 + 35 002c C001 movw r24,r0 + 36 002e C39F mul r28,r19 + 37 0030 900D add r25,r0 + 38 0032 1124 clr __zero_reg__ + 39 0034 9093 0000 sts voltage_gen+1,r25 + 40 0038 8093 0000 sts voltage_gen,r24 + 41 003c 64E0 ldi r22,lo8(4) + 42 003e 81E0 ldi r24,lo8(1) + 43 0040 00D0 rcall adc_read_avg + 44 0042 8F5F subi r24,-1 + 45 0044 9140 sbci r25,1 + 46 0046 97FD sbrc r25,7 + 47 0048 00C0 rjmp .L2 + 48 004a 9093 0000 sts temp.1586+1,r25 + 49 004e 8093 0000 sts temp.1586,r24 + 50 0052 00C0 rjmp .L3 + 51 .L2: + 52 0054 1092 0000 sts temp.1586+1,__zero_reg__ + 53 0058 1092 0000 sts temp.1586,__zero_reg__ + 54 .L3: + 55 005c 2091 0000 lds r18,temp.1586 + 56 0060 3091 0000 lds r19,temp.1586+1 + 57 0064 48E4 ldi r20,lo8(72) + 58 0066 429F mul r20,r18 + 59 0068 C001 movw r24,r0 + 60 006a 439F mul r20,r19 + 61 006c 900D add r25,r0 + 62 006e 1124 clr __zero_reg__ + 63 0070 9093 0000 sts current_in+1,r25 + 64 0074 8093 0000 sts current_in,r24 + 65 /* epilogue start */ + 66 0078 CF91 pop r28 + 67 007a 0895 ret + 69 .global get_power + 71 get_power: + 72 007c CF93 push r28 + 73 007e DF93 push r29 + 74 /* prologue: function */ + 75 /* frame size = 0 */ + 76 /* stack size = 2 */ + 77 .L__stack_usage = 2 + 78 0080 EC01 movw r28,r24 + 79 0082 CB01 movw r24,r22 + 80 0084 24E6 ldi r18,lo8(100) + 81 0086 30E0 ldi r19,0 + 82 0088 B901 movw r22,r18 + 83 008a 00D0 rcall __divmodhi4 + 84 008c FB01 movw r30,r22 + 85 008e CE01 movw r24,r28 + 86 0090 B901 movw r22,r18 + 87 0092 00D0 rcall __udivmodhi4 + 88 0094 E69F mul r30,r22 + 89 0096 C001 movw r24,r0 + 90 0098 E79F mul r30,r23 + 91 009a 900D add r25,r0 + 92 009c F69F mul r31,r22 + 93 009e 900D add r25,r0 + 94 00a0 1124 clr r1 + 95 00a2 B901 movw r22,r18 + 96 00a4 00D0 rcall __udivmodhi4 + 97 00a6 CB01 movw r24,r22 + 98 /* epilogue start */ + 99 00a8 DF91 pop r29 + 100 00aa CF91 pop r28 + 101 00ac 0895 ret + 103 .global pretty_print_all_values + 105 pretty_print_all_values: + 106 /* prologue: function */ + 107 /* frame size = 0 */ + 108 /* stack size = 0 */ + 109 .L__stack_usage = 0 + 110 00ae 80E0 ldi r24,lo8(__c.1594) + 111 00b0 90E0 ldi r25,hi8(__c.1594) + 112 00b2 00D0 rcall uart_puts_p + 113 00b4 8091 0000 lds r24,voltage_bat + 114 00b8 9091 0000 lds r25,voltage_bat+1 + 115 00bc 00D0 rcall uart_print_uint16 + 116 00be 80E0 ldi r24,lo8(__c.1596) + 117 00c0 90E0 ldi r25,hi8(__c.1596) + 118 00c2 00D0 rcall uart_puts_p + 119 00c4 80E0 ldi r24,lo8(__c.1598) + 120 00c6 90E0 ldi r25,hi8(__c.1598) + 121 00c8 00D0 rcall uart_puts_p + 122 00ca 8091 0000 lds r24,voltage_gen + 123 00ce 9091 0000 lds r25,voltage_gen+1 + 124 00d2 00D0 rcall uart_print_uint16 + 125 00d4 80E0 ldi r24,lo8(__c.1600) + 126 00d6 90E0 ldi r25,hi8(__c.1600) + 127 00d8 00D0 rcall uart_puts_p + 128 00da 80E0 ldi r24,lo8(__c.1602) + 129 00dc 90E0 ldi r25,hi8(__c.1602) + 130 00de 00D0 rcall uart_puts_p + 131 00e0 8091 0000 lds r24,current_in + 132 00e4 9091 0000 lds r25,current_in+1 + 133 00e8 00D0 rcall uart_print_uint16 + 134 00ea 80E0 ldi r24,lo8(__c.1604) + 135 00ec 90E0 ldi r25,hi8(__c.1604) + 136 00ee 00D0 rcall uart_puts_p + 137 00f0 8091 0000 lds r24,current_in + 138 00f4 9091 0000 lds r25,current_in+1 + 139 00f8 24E6 ldi r18,lo8(100) + 140 00fa 30E0 ldi r19,0 + 141 00fc B901 movw r22,r18 + 142 00fe 00D0 rcall __divmodhi4 + 143 0100 FB01 movw r30,r22 + 144 0102 8091 0000 lds r24,voltage_bat + 145 0106 9091 0000 lds r25,voltage_bat+1 + 146 010a B901 movw r22,r18 + 147 010c 00D0 rcall __udivmodhi4 + 148 010e E69F mul r30,r22 + 149 0110 C001 movw r24,r0 + 150 0112 E79F mul r30,r23 + 151 0114 900D add r25,r0 + 152 0116 F69F mul r31,r22 + 153 0118 900D add r25,r0 + 154 011a 1124 clr r1 + 155 011c B901 movw r22,r18 + 156 011e 00D0 rcall __udivmodhi4 + 157 0120 CB01 movw r24,r22 + 158 0122 00D0 rcall uart_print_uint16 + 159 0124 80E0 ldi r24,lo8(__c.1606) + 160 0126 90E0 ldi r25,hi8(__c.1606) + 161 0128 00D0 rcall uart_puts_p + 162 012a 80E0 ldi r24,lo8(__c.1608) + 163 012c 90E0 ldi r25,hi8(__c.1608) + 164 012e 00D0 rcall uart_puts_p + 165 0130 86B3 in r24,0x16 + 166 0132 8170 andi r24,lo8(1) + 167 0134 805D subi r24,lo8(-(48)) + 168 0136 00D0 rcall uart_putc + 169 0138 8CE2 ldi r24,lo8(44) + 170 013a 00D0 rcall uart_putc + 171 013c 86B3 in r24,0x16 + 172 013e 8695 lsr r24 + 173 0140 8170 andi r24,1 + 174 0142 805D subi r24,lo8(-(48)) + 175 0144 00D0 rcall uart_putc + 176 0146 80E0 ldi r24,lo8(__c.1610) + 177 0148 90E0 ldi r25,hi8(__c.1610) + 178 014a 00C0 rjmp uart_puts_p + 180 .global handle_over_and_undervoltage + 182 handle_over_and_undervoltage: + 183 /* prologue: function */ + 184 /* frame size = 0 */ + 185 /* stack size = 0 */ + 186 .L__stack_usage = 0 + 187 014c 8091 0000 lds r24,voltage_bat + 188 0150 9091 0000 lds r25,voltage_bat+1 + 189 0154 803C cpi r24,-64 + 190 0156 9B42 sbci r25,43 + 191 0158 00F4 brsh .L7 + 192 015a 1092 0000 sts undervoltage_off_counter,__zero_reg__ + 193 015e 8091 0000 lds r24,undervoltage_counter + 194 0162 8530 cpi r24,lo8(5) + 195 0164 00F4 brsh .L9 + 196 0166 8F5F subi r24,lo8(-(1)) + 197 0168 8093 0000 sts undervoltage_counter,r24 + 198 016c 00C0 rjmp .L9 + 199 .L7: + 200 016e 1092 0000 sts undervoltage_counter,__zero_reg__ + 201 0172 8091 0000 lds r24,undervoltage_off_counter + 202 0176 8330 cpi r24,lo8(3) + 203 0178 00F4 brsh .L9 + 204 017a 8F5F subi r24,lo8(-(1)) + 205 017c 8093 0000 sts undervoltage_off_counter,r24 + 206 .L9: + 207 0180 8091 0000 lds r24,voltage_gen + 208 0184 9091 0000 lds r25,voltage_gen+1 + 209 0188 893C cpi r24,-55 + 210 018a 9243 sbci r25,50 + 211 018c 00F0 brlo .L11 + 212 018e 1092 0000 sts generator_off_counter,__zero_reg__ + 213 0192 8091 0000 lds r24,generator_counter + 214 0196 8330 cpi r24,lo8(3) + 215 0198 00F4 brsh .L13 + 216 019a 8F5F subi r24,lo8(-(1)) + 217 019c 8093 0000 sts generator_counter,r24 + 218 01a0 00C0 rjmp .L13 + 219 .L11: + 220 01a2 1092 0000 sts generator_counter,__zero_reg__ + 221 01a6 8091 0000 lds r24,generator_off_counter + 222 01aa 8111 cpse r24,__zero_reg__ + 223 01ac 00C0 rjmp .L13 + 224 01ae 81E0 ldi r24,lo8(1) + 225 01b0 8093 0000 sts generator_off_counter,r24 + 226 .L13: + 227 01b4 8091 0000 lds r24,undervoltage_counter + 228 01b8 8530 cpi r24,lo8(5) + 229 01ba 00F0 brlo .L15 + 230 01bc 1092 0000 sts undervoltage_off_counter,__zero_reg__ + 231 01c0 00C0 rjmp .L23 + 232 .L15: + 233 01c2 8091 0000 lds r24,undervoltage_off_counter + 234 01c6 8330 cpi r24,lo8(3) + 235 01c8 00F0 brlo .L6 + 236 01ca 1092 0000 sts undervoltage_counter,__zero_reg__ + 237 01ce 8091 0000 lds r24,generator_counter + 238 01d2 8330 cpi r24,lo8(3) + 239 01d4 00F0 brlo .L18 + 240 01d6 C09A sbi 0x18,0 + 241 01d8 0895 ret + 242 .L18: + 243 01da 8091 0000 lds r24,generator_off_counter + 244 01de 8111 cpse r24,__zero_reg__ + 245 .L23: + 246 01e0 C098 cbi 0x18,0 + 247 .L6: + 248 01e2 0895 ret + 250 .section .text.startup,"ax",@progbits + 251 .global main + 253 main: + 254 /* prologue: function */ + 255 /* frame size = 0 */ + 256 /* stack size = 0 */ + 257 .L__stack_usage = 0 + 258 0000 87B3 in r24,0x17 + 259 0002 8360 ori r24,lo8(3) + 260 0004 87BB out 0x17,r24 + 261 0006 88B3 in r24,0x18 + 262 0008 8C7F andi r24,lo8(-4) + 263 000a 88BB out 0x18,r24 + 264 000c 00D0 rcall adc_init + 265 000e 8EB5 in r24,0x2e + 266 0010 8B60 ori r24,lo8(11) + 267 0012 8EBD out 0x2e,r24 + 268 0014 82EE ldi r24,lo8(-30) + 269 0016 94E0 ldi r25,lo8(4) + 270 0018 9BBD out 0x2a+1,r25 + 271 001a 8ABD out 0x2a,r24 + 272 001c 80E1 ldi r24,lo8(16) + 273 001e 89BF out 0x39,r24 + 274 /* #APP */ + 275 ; 27 "src/main.c" 1 + 276 0020 7894 sei + 277 ; 0 "" 2 + 278 /* #NOAPP */ + 279 0022 89E1 ldi r24,lo8(25) + 280 0024 90E0 ldi r25,0 + 281 0026 00D0 rcall uart_init + 282 0028 C098 cbi 0x18,0 + 283 002a C19A sbi 0x18,1 + 284 002c C4E6 ldi r28,lo8(100) + 285 002e D0E0 ldi r29,0 + 286 .L35: + 287 0030 8091 0000 lds r24,syscounter + 288 0034 9091 0000 lds r25,syscounter+1 + 289 0038 8436 cpi r24,100 + 290 003a 9105 cpc r25,__zero_reg__ + 291 003c 00F0 brlo .L27 + 292 003e 1092 0000 sts syscounter+1,__zero_reg__ + 293 0042 1092 0000 sts syscounter,__zero_reg__ + 294 0046 00D0 rcall measure + 295 0048 00D0 rcall handle_over_and_undervoltage + 296 .L27: + 297 004a 00D0 rcall uart_getc + 298 004c 8115 cp r24,__zero_reg__ + 299 004e 21E0 ldi r18,1 + 300 0050 9207 cpc r25,r18 + 301 0052 01F0 breq .L35 + 302 0054 9927 clr r25 + 303 0056 8136 cpi r24,97 + 304 0058 9105 cpc r25,__zero_reg__ + 305 005a 01F0 breq .L28 + 306 005c 8037 cpi r24,112 + 307 005e 9105 cpc r25,__zero_reg__ + 308 0060 01F4 brne .L35 + 309 0062 00D0 rcall pretty_print_all_values + 310 0064 00C0 rjmp .L35 + 311 .L28: + 312 0066 81E4 ldi r24,lo8(65) + 313 0068 00D0 rcall uart_putc + 314 006a 8091 0000 lds r24,voltage_bat + 315 006e 9091 0000 lds r25,voltage_bat+1 + 316 0072 00D0 rcall uart_print_uint16 + 317 0074 8CE2 ldi r24,lo8(44) + 318 0076 00D0 rcall uart_putc + 319 0078 8091 0000 lds r24,current_in + 320 007c 9091 0000 lds r25,current_in+1 + 321 0080 00D0 rcall uart_print_uint16 + 322 0082 8CE2 ldi r24,lo8(44) + 323 0084 00D0 rcall uart_putc + 324 0086 80E0 ldi r24,0 + 325 0088 90E0 ldi r25,0 + 326 008a 00D0 rcall uart_print_uint16 + 327 008c 8CE2 ldi r24,lo8(44) + 328 008e 00D0 rcall uart_putc + 329 0090 8091 0000 lds r24,current_in + 330 0094 9091 0000 lds r25,current_in+1 + 331 0098 BE01 movw r22,r28 + 332 009a 00D0 rcall __divmodhi4 + 333 009c 9B01 movw r18,r22 + 334 009e 8091 0000 lds r24,voltage_bat + 335 00a2 9091 0000 lds r25,voltage_bat+1 + 336 00a6 BE01 movw r22,r28 + 337 00a8 00D0 rcall __udivmodhi4 + 338 00aa 269F mul r18,r22 + 339 00ac C001 movw r24,r0 + 340 00ae 279F mul r18,r23 + 341 00b0 900D add r25,r0 + 342 00b2 369F mul r19,r22 + 343 00b4 900D add r25,r0 + 344 00b6 1124 clr r1 + 345 00b8 BE01 movw r22,r28 + 346 00ba 00D0 rcall __udivmodhi4 + 347 00bc CB01 movw r24,r22 + 348 00be 00D0 rcall uart_print_uint16 + 349 00c0 8CE2 ldi r24,lo8(44) + 350 00c2 00D0 rcall uart_putc + 351 00c4 80E0 ldi r24,0 + 352 00c6 90E0 ldi r25,0 + 353 00c8 00D0 rcall uart_print_uint16 + 354 00ca 8CE2 ldi r24,lo8(44) + 355 00cc 00D0 rcall uart_putc + 356 00ce 86B3 in r24,0x16 + 357 00d0 8170 andi r24,lo8(1) + 358 00d2 805D subi r24,lo8(-(48)) + 359 00d4 00D0 rcall uart_putc + 360 00d6 8CE2 ldi r24,lo8(44) + 361 00d8 00D0 rcall uart_putc + 362 00da 80E3 ldi r24,lo8(48) + 363 00dc 00D0 rcall uart_putc + 364 00de 8CE2 ldi r24,lo8(44) + 365 00e0 00D0 rcall uart_putc + 366 00e2 86B3 in r24,0x16 + 367 00e4 8695 lsr r24 + 368 00e6 8170 andi r24,1 + 369 00e8 805D subi r24,lo8(-(48)) + 370 00ea 00D0 rcall uart_putc + 371 00ec 82E4 ldi r24,lo8(66) + 372 00ee 00D0 rcall uart_putc + 373 00f0 00C0 rjmp .L35 + 375 .text + 376 .global __vector_6 + 378 __vector_6: + 379 01e4 1F92 push r1 + 380 01e6 0F92 push r0 + 381 01e8 0FB6 in r0,__SREG__ + 382 01ea 0F92 push r0 + 383 01ec 1124 clr __zero_reg__ + 384 01ee 2F93 push r18 + 385 01f0 3F93 push r19 + 386 01f2 4F93 push r20 + 387 01f4 5F93 push r21 + 388 01f6 6F93 push r22 + 389 01f8 7F93 push r23 + 390 01fa 8F93 push r24 + 391 01fc 9F93 push r25 + 392 /* prologue: Signal */ + 393 /* frame size = 0 */ + 394 /* stack size = 11 */ + 395 .L__stack_usage = 11 + 396 01fe 8091 0000 lds r24,syscounter + 397 0202 9091 0000 lds r25,syscounter+1 + 398 0206 0196 adiw r24,1 + 399 0208 9093 0000 sts syscounter+1,r25 + 400 020c 8093 0000 sts syscounter,r24 + 401 0210 2091 0000 lds r18,syscounter + 402 0214 3091 0000 lds r19,syscounter+1 + 403 0218 81E0 ldi r24,lo8(1) + 404 021a 90E0 ldi r25,0 + 405 021c 2036 cpi r18,96 + 406 021e 4AEE ldi r20,-22 + 407 0220 3407 cpc r19,r20 + 408 0222 00F4 brsh .L37 + 409 0224 80E0 ldi r24,0 + 410 0226 90E0 ldi r25,0 + 411 .L37: + 412 0228 60E6 ldi r22,lo8(96) + 413 022a 7AEE ldi r23,lo8(-22) + 414 022c 869F mul r24,r22 + 415 022e A001 movw r20,r0 + 416 0230 879F mul r24,r23 + 417 0232 500D add r21,r0 + 418 0234 969F mul r25,r22 + 419 0236 500D add r21,r0 + 420 0238 1124 clr r1 + 421 023a C901 movw r24,r18 + 422 023c 841B sub r24,r20 + 423 023e 950B sbc r25,r21 + 424 0240 9093 0000 sts syscounter+1,r25 + 425 0244 8093 0000 sts syscounter,r24 + 426 /* epilogue start */ + 427 0248 9F91 pop r25 + 428 024a 8F91 pop r24 + 429 024c 7F91 pop r23 + 430 024e 6F91 pop r22 + 431 0250 5F91 pop r21 + 432 0252 4F91 pop r20 + 433 0254 3F91 pop r19 + 434 0256 2F91 pop r18 + 435 0258 0F90 pop r0 + 436 025a 0FBE out __SREG__,r0 + 437 025c 0F90 pop r0 + 438 025e 1F90 pop r1 + 439 0260 1895 reti + 441 .global generator_off_counter + 442 .section .bss + 445 generator_off_counter: + 446 0000 00 .zero 1 + 447 .global generator_counter + 450 generator_counter: + 451 0001 00 .zero 1 + 452 .global undervoltage_off_counter + 455 undervoltage_off_counter: + 456 0002 00 .zero 1 + 457 .global undervoltage_counter + 460 undervoltage_counter: + 461 0003 00 .zero 1 + 462 .global overvoltage_off_counter + 465 overvoltage_off_counter: + 466 0004 00 .zero 1 + 467 .global overvoltage_counter + 470 overvoltage_counter: + 471 0005 00 .zero 1 + 472 .global current_in + 475 current_in: + 476 0006 0000 .zero 2 + 477 .global voltage_gen + 480 voltage_gen: + 481 0008 0000 .zero 2 + 482 .global voltage_bat + 485 voltage_bat: + 486 000a 0000 .zero 2 + 487 .global syscounter + 490 syscounter: + 491 000c 0000 .zero 2 + 492 .local temp.1586 + 493 .comm temp.1586,2,1 + 494 .section .progmem.data,"a",@progbits + 497 __c.1594: + 498 0000 4261 7474 .string "Battery Voltage: " + 498 6572 7920 + 498 566F 6C74 + 498 6167 653A + 498 2020 2000 + 501 __c.1596: + 502 0014 6D56 0D0A .string "mV\r\n" + 502 00 + 505 __c.1598: + 506 0019 4765 6E65 .string "Generator Voltage: " + 506 7261 746F + 506 7220 566F + 506 6C74 6167 + 506 653A 2020 + 509 __c.1600: + 510 002f 6D56 0D0A .string "mV\r\n" + 510 00 + 513 __c.1602: + 514 0034 4765 6E65 .string "Generator: " + 514 7261 746F + 514 723A 2000 + 517 __c.1604: + 518 0040 6D41 2020 .string "mA " + 518 00 + 521 __c.1606: + 522 0045 570D 0A00 .string "W\r\n" + 525 __c.1608: + 526 0049 7377 6974 .string "switches (load, gen): " + 526 6368 6573 + 526 2028 6C6F + 526 6164 2C20 + 526 6765 6E29 + 529 __c.1610: + 530 0060 0D0A 00 .string "\r\n" + 531 .ident "GCC: (GNU) 4.7.2" + 532 .global __do_clear_bss +DEFINED SYMBOLS + *ABS*:0000000000000000 main.c + /tmp/ccKzr9U4.s:2 *ABS*:000000000000003e __SP_H__ + /tmp/ccKzr9U4.s:3 *ABS*:000000000000003d __SP_L__ + /tmp/ccKzr9U4.s:4 *ABS*:000000000000003f __SREG__ + /tmp/ccKzr9U4.s:5 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccKzr9U4.s:6 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccKzr9U4.s:10 .text:0000000000000000 measure + /tmp/ccKzr9U4.s:485 .bss:000000000000000a voltage_bat + /tmp/ccKzr9U4.s:480 .bss:0000000000000008 voltage_gen + .bss:000000000000000e temp.1586 + /tmp/ccKzr9U4.s:475 .bss:0000000000000006 current_in + /tmp/ccKzr9U4.s:71 .text:000000000000007c get_power + /tmp/ccKzr9U4.s:105 .text:00000000000000ae pretty_print_all_values + /tmp/ccKzr9U4.s:497 .progmem.data:0000000000000000 __c.1594 + /tmp/ccKzr9U4.s:501 .progmem.data:0000000000000014 __c.1596 + /tmp/ccKzr9U4.s:505 .progmem.data:0000000000000019 __c.1598 + /tmp/ccKzr9U4.s:509 .progmem.data:000000000000002f __c.1600 + /tmp/ccKzr9U4.s:513 .progmem.data:0000000000000034 __c.1602 + /tmp/ccKzr9U4.s:517 .progmem.data:0000000000000040 __c.1604 + /tmp/ccKzr9U4.s:521 .progmem.data:0000000000000045 __c.1606 + /tmp/ccKzr9U4.s:525 .progmem.data:0000000000000049 __c.1608 + /tmp/ccKzr9U4.s:529 .progmem.data:0000000000000060 __c.1610 + /tmp/ccKzr9U4.s:182 .text:000000000000014c handle_over_and_undervoltage + /tmp/ccKzr9U4.s:455 .bss:0000000000000002 undervoltage_off_counter + /tmp/ccKzr9U4.s:460 .bss:0000000000000003 undervoltage_counter + /tmp/ccKzr9U4.s:445 .bss:0000000000000000 generator_off_counter + /tmp/ccKzr9U4.s:450 .bss:0000000000000001 generator_counter + /tmp/ccKzr9U4.s:253 .text.startup:0000000000000000 main + /tmp/ccKzr9U4.s:490 .bss:000000000000000c syscounter + /tmp/ccKzr9U4.s:378 .text:00000000000001e4 __vector_6 + /tmp/ccKzr9U4.s:465 .bss:0000000000000004 overvoltage_off_counter + /tmp/ccKzr9U4.s:470 .bss:0000000000000005 overvoltage_counter + +UNDEFINED SYMBOLS +adc_read_avg +__divmodhi4 +__udivmodhi4 +uart_puts_p +uart_print_uint16 +uart_putc +adc_init +uart_init +uart_getc +__do_clear_bss diff --git a/display_v2/software/powerboard_v2/src/main.o b/display_v2/software/powerboard_v2/src/main.o new file mode 100644 index 0000000000000000000000000000000000000000..b82321e6260ed62c0354e0e9ccf890c6320ee131 GIT binary patch literal 4756 zcmb7He~eUD6~2$z!a||T5{qcH9dNT%Fy}JbI3sh4z;}7A55srNyH{P=W;^ z!jR5e8xVP;7g@0;3-x1@#dnJz7}t!Zsc_||hA98T_>Dn51@>RS{>U3a&o$%S0!QR3 zBbYIVm?ID%-~NBRa%^o*741LGJad-eiF`Wu4N*RNQ zSUOcd_Q+_%Xv6u2(Z;6L#r4JRqFGE8_ZN>B$BSxqzUendwBe;ad3RwqLYxure7OF4~^Zg#*G(_7xouY1+&mySYKFOXc%d@)G+eM$g;76 z6EF50eDl!6(fxsGPZYRk13f%zya@msdvT8Pnf+G>=|mI`=rfchOVI-@-m2Z~t6ycV=1M8PWZhaIVf6 zibbm#=k8IQxrle}=(z^*##Be^`=9&M>~nAcS%}gG%XMvMPjE*n?pl3zTQC?Di5-g; zh%I)~b}TpL{FkmaaKC~9Ujsk$!hjp?w==<(c*=^c3ijE_mFP#0*s^hBTd-xzlh3RS zwuT-Ltra4a*^_XsUTD|xb-zN69k)WRz1tO`-b_Y>sy4Wm<7U$$ly*{m2|E#rS*|5Q z(NrQ~CtdHJ_}@N3(0JF(m2}=Qy>p}irS74JfN>2~+s^xiXt_@aEXm`rZy}^Z+5u>` zlUgj=Dqb^iJw)d%CP6mE3&Ym)W4sR)N%qnFJVeiL2*DPE%lwe0*T?+63}HN#)*&Pi zg{_*Jw+jwp&d>HY@Rs<{`?8PH2vKWb$Hy?9A&^bQqgHdWs}%)b3@*wjJ_%v&T>pHC z9&ZyI%d~+i9%wU~?ynPf?&+NYFVmVQFk=SJSLf{oYvZ>&_qeVvDHHKN4ZL2nKUc*B zckZpmx0b`5d+T670AcC|;`3aveF9>Ld7@il?hWl{p+5y#Ds2mzF;)Nbz&xAWL-I4w z?GV-fP2kNC){*@$L4Os(+R{D--2-85Y3nWEMX7lL|JGkGUY6aQX9*&V*XZ89y$+ja zjq7bh7C(XJ`BwH7U~GBSo&;trTmW9Y-$Sd$bMR+nK-1=#{{iGx2x@@LtCl=lJQ2a5D8Lt66{vci@I8@mSb?<)NOB}B$&s)kuL+BU zZDq2KEv#4+lUXs-8tfB;{`+F~T5c8Ni4f7O3%V4InZpKVY>@l*St%+27qoUtR#^Sb_8nhh~ z(99-dwj)y$x?!ev?J}dOY!Z*-%ns#5^8WicgIe<{9{0#A#Xxev^;7XsW=}>@yzH@h z?&P2y#hYtJ1ankH)05HtDgf%0GNWfr9-co}S za~($@fzRTDHVO$m>_Kr(!@MKrKIr>@2sKaQH^>S4{_{}GnQOlwF>CTONMJcWXqO<2 z!~41fVI1Pi5EbVNFgd)pe+40j_$owkt^;!}*03xwYx@>N&2t56n32&>uh;hxj%`#rY6e#ra5L#`z~X zvi^0vpJWZ|C1wp50;_#_Si>ubmxF-T1k4=xUNr+V2V&mYDu>4;hi}*_$srDDoCxs> zIMLcPyh+0yz?`cGoK9fQMZA@qAOPBvz-leqCFWY51)eiUh$Qq*>4zzLB<6b&lbjs% z^O`>n%=1rwTJyUSGtO>c#wTZ==06}Y&&;sIJTpgu$^S0&i1foPPDl(TPT@n&kDy=G z{AYog5B=vf|7#L6&g&ZI4b6XEVy^cBFymi_#{V?Dy1^7BV8*XNU(x(mfyuuKeO>w) zrz|m)xPcEjZ$rN${cywS$LG6QC-EZS1sZ-p<1EqeQjN0$nDJX68#I51#Eee~ti%Vc z84`HRgWlgKJR9tfK!};cI>;Pc2wS1sAI>Tv+d4?TGU^zZ$gAm2v3rzl8=zS9NH=cti z{t&T@e?;>i)BK~rD$YrX8Rs-P@~${5{R^PaNzB|{gQ&aWf`)nbsvIs8%N(w1{_C3m chK9X6Q}TIFs<9Ofzpr8M-jn=k`ekkZ1*qixn*aa+ literal 0 HcmV?d00001 diff --git a/display_v2/software/powerboard_v2/src/uart.c b/display_v2/software/powerboard_v2/src/uart.c new file mode 100644 index 0000000..67f8581 --- /dev/null +++ b/display_v2/software/powerboard_v2/src/uart.c @@ -0,0 +1,663 @@ +/************************************************************************* +Title: Interrupt UART library with receive/transmit circular buffers +Author: Peter Fleury http://jump.to/fleury +File: $Id: uart.c,v 1.10 2013/06/02 07:27:04 peter Exp $ +Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher +Hardware: any AVR with built-in UART, +License: GNU General Public License + +DESCRIPTION: + An interrupt is generated when the UART has finished transmitting or + receiving a byte. The interrupt handling routines use circular buffers + for buffering received and transmitted data. + + The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define + the buffer size in bytes. Note that these variables must be a + power of 2. + +USAGE: + Refere to the header file uart.h for a description of the routines. + See also example test_uart.c. + +NOTES: + Based on Atmel Application Note AVR306 + +LICENSE: + Copyright (C) 2006 Peter Fleury + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*************************************************************************/ +#include +#include +#include +#include "uart.h" + + +/* + * constants and macros + */ + +/* size of RX/TX buffers */ +#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1) +#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1) + +#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK ) +#error RX buffer size is not a power of 2 +#endif +#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK ) +#error TX buffer size is not a power of 2 +#endif + +#if defined(__AVR_AT90S2313__) \ + || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ + || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ + || defined(__AVR_ATmega103__) + /* old AVR classic or ATmega103 with one UART */ + #define AT90_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS USR + #define UART0_CONTROL UCR + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) + /* old AVR classic with one UART */ + #define AT90_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ + || defined(__AVR_ATmega323__) + /* ATmega with one USART */ + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RXC_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega163__) + /* ATmega163 with one UART */ + #define ATMEGA_UART + #define UART0_RECEIVE_INTERRUPT UART_RX_vect + #define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega162__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect + #define UART1_RECEIVE_INTERRUPT USART1_RXC_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega161__) + /* ATmega with UART */ + #error "AVR ATmega161 currently not supported by this libaray !" +#elif defined(__AVR_ATmega169__) + /* ATmega with one USART */ + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \ + || defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATtiny2313__) + #define ATMEGA_USART + #define UART0_RECEIVE_INTERRUPT USART_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect + #define UART0_STATUS UCSRA + #define UART0_CONTROL UCSRB + #define UART0_DATA UDR + #define UART0_UDRIE UDRIE +#elif defined(__AVR_ATmega329__) || \ + defined(__AVR_ATmega649__) || \ + defined(__AVR_ATmega325__) || \ + defined(__AVR_ATmega645__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) +/* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#elif defined(__AVR_ATmega644__) + /* ATmega with one USART */ + #define ATMEGA_USART0 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 +#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) + /* ATmega with two USART */ + #define ATMEGA_USART0 + #define ATMEGA_USART1 + #define UART0_RECEIVE_INTERRUPT USART0_RX_vect + #define UART1_RECEIVE_INTERRUPT USART1_RX_vect + #define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect + #define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect + #define UART0_STATUS UCSR0A + #define UART0_CONTROL UCSR0B + #define UART0_DATA UDR0 + #define UART0_UDRIE UDRIE0 + #define UART1_STATUS UCSR1A + #define UART1_CONTROL UCSR1B + #define UART1_DATA UDR1 + #define UART1_UDRIE UDRIE1 +#else + #error "no UART definition for MCU available" +#endif + + +/* + * module global variables + */ +static volatile unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE]; +static volatile unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE]; +static volatile unsigned char UART_TxHead; +static volatile unsigned char UART_TxTail; +static volatile unsigned char UART_RxHead; +static volatile unsigned char UART_RxTail; +static volatile unsigned char UART_LastRxError; + +#if defined( ATMEGA_USART1 ) +static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE]; +static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE]; +static volatile unsigned char UART1_TxHead; +static volatile unsigned char UART1_TxTail; +static volatile unsigned char UART1_RxHead; +static volatile unsigned char UART1_RxTail; +static volatile unsigned char UART1_LastRxError; +#endif + + + +ISR (UART0_RECEIVE_INTERRUPT) +/************************************************************************* +Function: UART Receive Complete interrupt +Purpose: called when the UART has received a character +**************************************************************************/ +{ + unsigned char tmphead; + unsigned char data; + unsigned char usr; + unsigned char lastRxError; + + + /* read UART status register and UART data register */ + usr = UART0_STATUS; + data = UART0_DATA; + + /* */ +#if defined( AT90_UART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#elif defined( ATMEGA_USART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#elif defined( ATMEGA_USART0 ) + lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) ); +#elif defined ( ATMEGA_UART ) + lastRxError = (usr & (_BV(FE)|_BV(DOR)) ); +#endif + + /* calculate buffer index */ + tmphead = ( UART_RxHead + 1) & UART_RX_BUFFER_MASK; + + if ( tmphead == UART_RxTail ) { + /* error: receive buffer overflow */ + lastRxError = UART_BUFFER_OVERFLOW >> 8; + }else{ + /* store new index */ + UART_RxHead = tmphead; + /* store received data in buffer */ + UART_RxBuf[tmphead] = data; + } + UART_LastRxError |= lastRxError; +} + + +ISR (UART0_TRANSMIT_INTERRUPT) +/************************************************************************* +Function: UART Data Register Empty interrupt +Purpose: called when the UART is ready to transmit the next byte +**************************************************************************/ +{ + unsigned char tmptail; + + + if ( UART_TxHead != UART_TxTail) { + /* calculate and store new buffer index */ + tmptail = (UART_TxTail + 1) & UART_TX_BUFFER_MASK; + UART_TxTail = tmptail; + /* get one byte from buffer and write it to UART */ + UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */ + }else{ + /* tx buffer empty, disable UDRE interrupt */ + UART0_CONTROL &= ~_BV(UART0_UDRIE); + } +} + + +/************************************************************************* +Function: uart_init() +Purpose: initialize UART and set baudrate +Input: baudrate using macro UART_BAUD_SELECT() +Returns: none +**************************************************************************/ +void uart_init(unsigned int baudrate) +{ + UART_TxHead = 0; + UART_TxTail = 0; + UART_RxHead = 0; + UART_RxTail = 0; + +#if defined( AT90_UART ) + /* set baud rate */ + UBRR = (unsigned char)baudrate; + + /* enable UART receiver and transmmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN); + +#elif defined (ATMEGA_USART) + /* Set baud rate */ + if ( baudrate & 0x8000 ) + { + UART0_STATUS = (1<>8); + UBRRL = (unsigned char) baudrate; + + /* Enable USART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|(1<>8); + UBRR0L = (unsigned char) baudrate; + + /* Enable USART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE0)|(1<>8); + UBRR = (unsigned char) baudrate; + + /* Enable UART receiver and transmitter and receive complete interrupt */ + UART0_CONTROL = _BV(RXCIE)|(1<> 8; + }else{ + /* store new index */ + UART1_RxHead = tmphead; + /* store received data in buffer */ + UART1_RxBuf[tmphead] = data; + } + UART1_LastRxError |= lastRxError; +} + + +ISR(UART1_TRANSMIT_INTERRUPT) +/************************************************************************* +Function: UART1 Data Register Empty interrupt +Purpose: called when the UART1 is ready to transmit the next byte +**************************************************************************/ +{ + unsigned char tmptail; + + + if ( UART1_TxHead != UART1_TxTail) { + /* calculate and store new buffer index */ + tmptail = (UART1_TxTail + 1) & UART_TX_BUFFER_MASK; + UART1_TxTail = tmptail; + /* get one byte from buffer and write it to UART */ + UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */ + }else{ + /* tx buffer empty, disable UDRE interrupt */ + UART1_CONTROL &= ~_BV(UART1_UDRIE); + } +} + + +/************************************************************************* +Function: uart1_init() +Purpose: initialize UART1 and set baudrate +Input: baudrate using macro UART_BAUD_SELECT() +Returns: none +**************************************************************************/ +void uart1_init(unsigned int baudrate) +{ + UART1_TxHead = 0; + UART1_TxTail = 0; + UART1_RxHead = 0; + UART1_RxTail = 0; + + + /* Set baud rate */ + if ( baudrate & 0x8000 ) + { + UART1_STATUS = (1<>8); + UBRR1L = (unsigned char) baudrate; + + /* Enable USART receiver and transmitter and receive complete interrupt */ + UART1_CONTROL = _BV(RXCIE1)|(1< http://jump.to/fleury +File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $ +Software: AVR-GCC 4.1, AVR Libc 1.4 +Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz +License: GNU General Public License +Usage: see Doxygen manual + +LICENSE: + Copyright (C) 2006 Peter Fleury + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +************************************************************************/ + +/** + * @defgroup pfleury_uart UART Library + * @code #include @endcode + * + * @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers. + * + * This library can be used to transmit and receive data through the built in UART. + * + * An interrupt is generated when the UART has finished transmitting or + * receiving a byte. The interrupt handling routines use circular buffers + * for buffering received and transmitted data. + * + * The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define + * the size of the circular buffers in bytes. Note that these constants must be a power of 2. + * You may need to adapt this constants to your target and your application by adding + * CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile. + * + * @note Based on Atmel Application Note AVR306 + * @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury + */ + +/**@{*/ + + +#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 +#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" +#endif + + +/* +** constants and macros +*/ + +/** @brief UART Baudrate Expression + * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz + * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 + */ +#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL) + +/** @brief UART Baudrate Expression for ATmega double speed mode + * @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz + * @param baudrate baudrate in bps, e.g. 1200, 2400, 9600 + */ +#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000) + + +/** Size of the circular receive buffer, must be power of 2 */ +#ifndef UART_RX_BUFFER_SIZE +#define UART_RX_BUFFER_SIZE 32 +#endif +/** Size of the circular transmit buffer, must be power of 2 */ +#ifndef UART_TX_BUFFER_SIZE +#define UART_TX_BUFFER_SIZE 32 +#endif + +/* test if the size of the circular buffers fits into SRAM */ +#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) ) +#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM" +#endif + +/* +** high byte error return code of uart_getc() +*/ +#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */ +#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */ +#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */ +#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */ +#define UART_NO_DATA 0x0100 /* no receive data available */ + + +/* +** function prototypes +*/ + +/** + @brief Initialize UART and set baudrate + @param baudrate Specify baudrate using macro UART_BAUD_SELECT() + @return none +*/ +extern void uart_init(unsigned int baudrate); + + +/** + * @brief Get received byte from ringbuffer + * + * Returns in the lower byte the received character and in the + * higher byte the last receive error. + * UART_NO_DATA is returned when no data is available. + * + * @param void + * @return lower byte: received byte from ringbuffer + * @return higher byte: last receive status + * - \b 0 successfully received data from UART + * - \b UART_NO_DATA + *
no receive data available + * - \b UART_BUFFER_OVERFLOW + *
Receive ringbuffer overflow. + * We are not reading the receive buffer fast enough, + * one or more received character have been dropped + * - \b UART_OVERRUN_ERROR + *
Overrun condition by UART. + * A character already present in the UART UDR register was + * not read by the interrupt handler before the next character arrived, + * one or more received characters have been dropped. + * - \b UART_FRAME_ERROR + *
Framing Error by UART + */ +extern unsigned int uart_getc(void); + + +/** + * @brief Put byte to ringbuffer for transmitting via UART + * @param data byte to be transmitted + * @return none + */ +extern void uart_putc(unsigned char data); + + +/** + * @brief Put string to ringbuffer for transmitting via UART + * + * The string is buffered by the uart library in a circular buffer + * and one character at a time is transmitted to the UART using interrupts. + * Blocks if it can not write the whole string into the circular buffer. + * + * @param s string to be transmitted + * @return none + */ +extern void uart_puts(const char *s ); + + +/** + * @brief Put string from program memory to ringbuffer for transmitting via UART. + * + * The string is buffered by the uart library in a circular buffer + * and one character at a time is transmitted to the UART using interrupts. + * Blocks if it can not write the whole string into the circular buffer. + * + * @param s program memory string to be transmitted + * @return none + * @see uart_puts_P + */ +extern void uart_puts_p(const char *s ); + +/** + * @brief Macro to automatically put a string constant into program memory + */ +#define uart_puts_P(__s) uart_puts_p(PSTR(__s)) + + + + +#endif // UART_H + diff --git a/display_v2/software/powerboard_v2/src/uart.lst b/display_v2/software/powerboard_v2/src/uart.lst new file mode 100644 index 0000000..6bc8ce9 --- /dev/null +++ b/display_v2/software/powerboard_v2/src/uart.lst @@ -0,0 +1,256 @@ + 1 .file "uart.c" + 2 __SP_H__ = 0x3e + 3 __SP_L__ = 0x3d + 4 __SREG__ = 0x3f + 5 __tmp_reg__ = 0 + 6 __zero_reg__ = 1 + 7 .text + 8 .global __vector_11 + 10 __vector_11: + 11 0000 1F92 push r1 + 12 0002 0F92 push r0 + 13 0004 0FB6 in r0,__SREG__ + 14 0006 0F92 push r0 + 15 0008 1124 clr __zero_reg__ + 16 000a 2F93 push r18 + 17 000c 8F93 push r24 + 18 000e 9F93 push r25 + 19 0010 EF93 push r30 + 20 0012 FF93 push r31 + 21 /* prologue: Signal */ + 22 /* frame size = 0 */ + 23 /* stack size = 8 */ + 24 .L__stack_usage = 8 + 25 0014 8BB1 in r24,0xb + 26 0016 9CB1 in r25,0xc + 27 0018 8871 andi r24,lo8(24) + 28 001a E091 0000 lds r30,UART_RxHead + 29 001e EF5F subi r30,lo8(-(1)) + 30 0020 EF71 andi r30,lo8(31) + 31 0022 2091 0000 lds r18,UART_RxTail + 32 0026 E217 cp r30,r18 + 33 0028 01F0 breq .L3 + 34 002a E093 0000 sts UART_RxHead,r30 + 35 002e F0E0 ldi r31,0 + 36 0030 E050 subi r30,lo8(-(UART_RxBuf)) + 37 0032 F040 sbci r31,hi8(-(UART_RxBuf)) + 38 0034 9083 st Z,r25 + 39 0036 00C0 rjmp .L2 + 40 .L3: + 41 0038 82E0 ldi r24,lo8(2) + 42 .L2: + 43 003a 9091 0000 lds r25,UART_LastRxError + 44 003e 982B or r25,r24 + 45 0040 9093 0000 sts UART_LastRxError,r25 + 46 /* epilogue start */ + 47 0044 FF91 pop r31 + 48 0046 EF91 pop r30 + 49 0048 9F91 pop r25 + 50 004a 8F91 pop r24 + 51 004c 2F91 pop r18 + 52 004e 0F90 pop r0 + 53 0050 0FBE out __SREG__,r0 + 54 0052 0F90 pop r0 + 55 0054 1F90 pop r1 + 56 0056 1895 reti + 58 .global __vector_12 + 60 __vector_12: + 61 0058 1F92 push r1 + 62 005a 0F92 push r0 + 63 005c 0FB6 in r0,__SREG__ + 64 005e 0F92 push r0 + 65 0060 1124 clr __zero_reg__ + 66 0062 8F93 push r24 + 67 0064 9F93 push r25 + 68 0066 EF93 push r30 + 69 0068 FF93 push r31 + 70 /* prologue: Signal */ + 71 /* frame size = 0 */ + 72 /* stack size = 7 */ + 73 .L__stack_usage = 7 + 74 006a 9091 0000 lds r25,UART_TxHead + 75 006e 8091 0000 lds r24,UART_TxTail + 76 0072 9817 cp r25,r24 + 77 0074 01F0 breq .L5 + 78 0076 E091 0000 lds r30,UART_TxTail + 79 007a EF5F subi r30,lo8(-(1)) + 80 007c EF71 andi r30,lo8(31) + 81 007e E093 0000 sts UART_TxTail,r30 + 82 0082 F0E0 ldi r31,0 + 83 0084 E050 subi r30,lo8(-(UART_TxBuf)) + 84 0086 F040 sbci r31,hi8(-(UART_TxBuf)) + 85 0088 8081 ld r24,Z + 86 008a 8CB9 out 0xc,r24 + 87 008c 00C0 rjmp .L4 + 88 .L5: + 89 008e 5598 cbi 0xa,5 + 90 .L4: + 91 /* epilogue start */ + 92 0090 FF91 pop r31 + 93 0092 EF91 pop r30 + 94 0094 9F91 pop r25 + 95 0096 8F91 pop r24 + 96 0098 0F90 pop r0 + 97 009a 0FBE out __SREG__,r0 + 98 009c 0F90 pop r0 + 99 009e 1F90 pop r1 + 100 00a0 1895 reti + 102 .global uart_init + 104 uart_init: + 105 /* prologue: function */ + 106 /* frame size = 0 */ + 107 /* stack size = 0 */ + 108 .L__stack_usage = 0 + 109 00a2 1092 0000 sts UART_TxHead,__zero_reg__ + 110 00a6 1092 0000 sts UART_TxTail,__zero_reg__ + 111 00aa 1092 0000 sts UART_RxHead,__zero_reg__ + 112 00ae 1092 0000 sts UART_RxTail,__zero_reg__ + 113 00b2 97FF sbrs r25,7 + 114 00b4 00C0 rjmp .L8 + 115 00b6 22E0 ldi r18,lo8(2) + 116 00b8 2BB9 out 0xb,r18 + 117 00ba 9F77 andi r25,127 + 118 .L8: + 119 00bc 90BD out 0x20,r25 + 120 00be 89B9 out 0x9,r24 + 121 00c0 88E9 ldi r24,lo8(-104) + 122 00c2 8AB9 out 0xa,r24 + 123 00c4 86E8 ldi r24,lo8(-122) + 124 00c6 80BD out 0x20,r24 + 125 00c8 0895 ret + 127 .global uart_getc + 129 uart_getc: + 130 /* prologue: function */ + 131 /* frame size = 0 */ + 132 /* stack size = 0 */ + 133 .L__stack_usage = 0 + 134 00ca 9091 0000 lds r25,UART_RxHead + 135 00ce 8091 0000 lds r24,UART_RxTail + 136 00d2 9817 cp r25,r24 + 137 00d4 01F0 breq .L11 + 138 00d6 E091 0000 lds r30,UART_RxTail + 139 00da EF5F subi r30,lo8(-(1)) + 140 00dc EF71 andi r30,lo8(31) + 141 00de E093 0000 sts UART_RxTail,r30 + 142 00e2 F0E0 ldi r31,0 + 143 00e4 E050 subi r30,lo8(-(UART_RxBuf)) + 144 00e6 F040 sbci r31,hi8(-(UART_RxBuf)) + 145 00e8 2081 ld r18,Z + 146 00ea 8091 0000 lds r24,UART_LastRxError + 147 00ee 1092 0000 sts UART_LastRxError,__zero_reg__ + 148 00f2 30E0 ldi r19,0 + 149 00f4 00C0 rjmp .L10 + 150 .L11: + 151 00f6 20E0 ldi r18,0 + 152 00f8 31E0 ldi r19,lo8(1) + 153 .L10: + 154 00fa C901 movw r24,r18 + 155 00fc 0895 ret + 157 .global uart_putc + 159 uart_putc: + 160 /* prologue: function */ + 161 /* frame size = 0 */ + 162 /* stack size = 0 */ + 163 .L__stack_usage = 0 + 164 00fe 9091 0000 lds r25,UART_TxHead + 165 0102 9F5F subi r25,lo8(-(1)) + 166 0104 9F71 andi r25,lo8(31) + 167 .L13: + 168 0106 2091 0000 lds r18,UART_TxTail + 169 010a 9217 cp r25,r18 + 170 010c 01F0 breq .L13 + 171 010e E92F mov r30,r25 + 172 0110 F0E0 ldi r31,0 + 173 0112 E050 subi r30,lo8(-(UART_TxBuf)) + 174 0114 F040 sbci r31,hi8(-(UART_TxBuf)) + 175 0116 8083 st Z,r24 + 176 0118 9093 0000 sts UART_TxHead,r25 + 177 011c 559A sbi 0xa,5 + 178 011e 0895 ret + 180 .global uart_puts + 182 uart_puts: + 183 0120 CF93 push r28 + 184 0122 DF93 push r29 + 185 /* prologue: function */ + 186 /* frame size = 0 */ + 187 /* stack size = 2 */ + 188 .L__stack_usage = 2 + 189 0124 EC01 movw r28,r24 + 190 0126 00C0 rjmp .L16 + 191 .L17: + 192 0128 00D0 rcall uart_putc + 193 .L16: + 194 012a 8991 ld r24,Y+ + 195 012c 8111 cpse r24,__zero_reg__ + 196 012e 00C0 rjmp .L17 + 197 /* epilogue start */ + 198 0130 DF91 pop r29 + 199 0132 CF91 pop r28 + 200 0134 0895 ret + 202 .global uart_puts_p + 204 uart_puts_p: + 205 0136 CF93 push r28 + 206 0138 DF93 push r29 + 207 /* prologue: function */ + 208 /* frame size = 0 */ + 209 /* stack size = 2 */ + 210 .L__stack_usage = 2 + 211 013a EC01 movw r28,r24 + 212 013c 00C0 rjmp .L19 + 213 .L20: + 214 013e 00D0 rcall uart_putc + 215 .L19: + 216 0140 FE01 movw r30,r28 + 217 0142 2196 adiw r28,1 + 218 /* #APP */ + 219 ; 474 "src/uart.c" 1 + 220 0144 8491 lpm r24, Z + 221 + 222 ; 0 "" 2 + 223 /* #NOAPP */ + 224 0146 8111 cpse r24,__zero_reg__ + 225 0148 00C0 rjmp .L20 + 226 /* epilogue start */ + 227 014a DF91 pop r29 + 228 014c CF91 pop r28 + 229 014e 0895 ret + 231 .local UART_LastRxError + 232 .comm UART_LastRxError,1,1 + 233 .local UART_RxTail + 234 .comm UART_RxTail,1,1 + 235 .local UART_RxHead + 236 .comm UART_RxHead,1,1 + 237 .local UART_TxTail + 238 .comm UART_TxTail,1,1 + 239 .local UART_TxHead + 240 .comm UART_TxHead,1,1 + 241 .local UART_RxBuf + 242 .comm UART_RxBuf,32,1 + 243 .local UART_TxBuf + 244 .comm UART_TxBuf,32,1 + 245 .ident "GCC: (GNU) 4.7.2" + 246 .global __do_clear_bss +DEFINED SYMBOLS + *ABS*:0000000000000000 uart.c + /tmp/ccbMxLMX.s:2 *ABS*:000000000000003e __SP_H__ + /tmp/ccbMxLMX.s:3 *ABS*:000000000000003d __SP_L__ + /tmp/ccbMxLMX.s:4 *ABS*:000000000000003f __SREG__ + /tmp/ccbMxLMX.s:5 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccbMxLMX.s:6 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccbMxLMX.s:10 .text:0000000000000000 __vector_11 + /tmp/ccbMxLMX.s:234 .bss:0000000000000002 UART_RxHead + /tmp/ccbMxLMX.s:232 .bss:0000000000000001 UART_RxTail + /tmp/ccbMxLMX.s:240 .bss:0000000000000005 UART_RxBuf + .bss:0000000000000000 UART_LastRxError + /tmp/ccbMxLMX.s:60 .text:0000000000000058 __vector_12 + /tmp/ccbMxLMX.s:238 .bss:0000000000000004 UART_TxHead + /tmp/ccbMxLMX.s:236 .bss:0000000000000003 UART_TxTail + /tmp/ccbMxLMX.s:242 .bss:0000000000000025 UART_TxBuf + /tmp/ccbMxLMX.s:104 .text:00000000000000a2 uart_init + /tmp/ccbMxLMX.s:129 .text:00000000000000ca uart_getc + /tmp/ccbMxLMX.s:159 .text:00000000000000fe uart_putc + /tmp/ccbMxLMX.s:182 .text:0000000000000120 uart_puts + /tmp/ccbMxLMX.s:204 .text:0000000000000136 uart_puts_p + +UNDEFINED SYMBOLS +__do_clear_bss diff --git a/display_v2/software/powerboard_v2/src/uart.o b/display_v2/software/powerboard_v2/src/uart.o new file mode 100644 index 0000000000000000000000000000000000000000..b2ebca3566a00768190018a19e2e9590d1c03d88 GIT binary patch literal 2008 zcmai!UuYav6voeV*O*9Qn;TC5@{ezpI z+*~{pg(7Qe?TiimIG@O7gZ6zwx^0{D_jd3;gxV8%vE#W=BnGP zPc3!onySpNa13ifS-VrSGJknlniJPdtxlyaHIcM^)RN|oXwP!vo$BpN%ZvBlU%vQz z<#zYdf7iF?IXCO;6Ep!^#EjYvSYXrMvaj`U6XvvT`Y$ z@0I3icsEQ(A6m~`T}buF@bTk^?Ec}`C!VwSJ1;u>M4ZyQGl6>&8u*F6WytrYT_^C$ zfjEyA*(CBPm^tj* z4BM^!43urb6iD3mn|c9$H!Phuq;n`{*r4XUx{vkxG*g&I>xG$GK)H(GA%bqqVWVQ% z?RF4@K1GmgVO{QH3#sb_qn>3CK)S|(1-#ItuInSaf|{%pLCBkh!p z7Weg1%HIlpIpsgwX2M2m0Kc6zY_tx;=YAQpP=BP&iJym$s}wtqXGKBTO#UpGXJY(w zV4jQd7s0z=b{u17r)5wXpF-T;z;7Q$HK63zwErdaGg!a&zk>b%<2z*jchHBh9ooMG zwK4e<+W!f906x!!`KwUVc#ksY`himrrA~~g5v39sO<;UzIEG+mR{7qkn9q8CQ9Bc_ zjOW#OdBk%kMRVSrnl^lF?#%>8-BK`K9`gO7p9J!$G5K<5Ouo!9O1Dd^gM7XL{J)XMG#>zGkk4<3Z;1J9$6$u1HM1*zCjh<;{`cWrA41D8<}+SN@dB9h z^6gxNabEIe80W1*KZkKF{^SeItaDv6(&UC_?(r6kW50p^sN>98(afBmVO-l^(0i$P zl;U5(=1hJAn=^T!b0D&w;y=Nh_iuJ!60_!R&0O +#include +#include "uart.h" + +void wait(uint8_t count) { + uint8_t i; + if(count == 0) count = 100; + for(i=0;i^_dMr0&pqed`@VNOx;r&Z zBWW7-Q8^=e%*iwtTWmoSRZ%5P)lzP{khV70etmC#rfpM>=%w+zo^rk?n{&mv>TF|n zIlG#j)vm3Lf1~___8>4hK>4MO&(?eGtwwn#f5f#VI}a8{Er(srEN2=s)tO>?Gfg?! zsd4V(!q){~AXuRM39?@e@FEgG$CZO)M=bkM|wu<=HGfIwg zIH%-CN*G|Pi2qdHVdwl^rCtrJt7GK_j=()`-p^4Q{==Y5I3ka-UuVaTc>fMZX{bMB zf6WdJ>XZ_ZXi^^{!|3ZZE*gddx*c%2qss;&Hfkh7!#2JhO2pk{+>8iHnF(QxCL$xk z7>h@RIUM2^sbFL*77vCaEp9y}hE!#W<)_QK8zr6H2i4|Q`yP1s{BidWuvaj~9maQn z$G<=5V%!fMct1bbTG>5#iS0bQ