Compare commits

...

2 Commits

Author SHA1 Message Date
true 03376cc654 Initial port of STM32L100 code
This code was originally written for use with the CooCox IDE back in 2014. It uses ST StdPeriphLib (SPL) as opposed to HAL.

I have ported this using the built-in board definition for a board that supports the SPL. After making some small changes (mostly to include paths, but also un-inlining a couple function calls) and removing dead code, it appears to compile cleanly.

Actual binary is untested.
2023-02-11 06:32:15 -08:00
true 1182c9b578 Rename ATTINY88 firmware directory (again)
I think I've settled on a filename structure
2023-02-11 06:29:53 -08:00
143 changed files with 21278 additions and 0 deletions

View File

@ -0,0 +1,152 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
SHELL := cmd.exe
RM := rm -rf
USER_OBJS :=
LIBS :=
PROJ :=
O_SRCS :=
C_SRCS :=
S_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
PREPROCESSING_SRCS :=
OBJS :=
OBJS_AS_ARGS :=
C_DEPS :=
C_DEPS_AS_ARGS :=
EXECUTABLES :=
OUTPUT_FILE_PATH :=
OUTPUT_FILE_PATH_AS_ARGS :=
AVR_APP_PATH :=$$$AVR_APP_PATH$$$
QUOTE := "
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:=
LIB_DEP:=
LINKER_SCRIPT_DEP:=
# Every subdirectory with source files must be described here
SUBDIRS := \
../src
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/adc.c \
../src/led.c \
../src/main.c
PREPROCESSING_SRCS +=
ASM_SRCS +=
OBJS += \
src/adc.o \
src/led.o \
src/main.o
OBJS_AS_ARGS += \
src/adc.o \
src/led.o \
src/main.o
C_DEPS += \
src/adc.d \
src/led.d \
src/main.d
C_DEPS_AS_ARGS += \
src/adc.d \
src/led.d \
src/main.d
OUTPUT_FILE_PATH +=wp_dc22_attiny88.elf
OUTPUT_FILE_PATH_AS_ARGS +=wp_dc22_attiny88.elf
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:= ./makedep.mk
LIB_DEP+=
LINKER_SCRIPT_DEP+=
# AVR32/GNU C Compiler
src/adc.o: ../src/adc.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include" -Os -finline-functions -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -Wextra -mmcu=attiny88 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny88" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
src/led.o: ../src/led.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include" -Os -finline-functions -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -Wextra -mmcu=attiny88 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny88" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
src/main.o: ../src/main.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include" -Os -finline-functions -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -Wextra -mmcu=attiny88 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny88" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
# AVR32/GNU Preprocessing Assembler
# AVR32/GNU Assembler
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)
$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
@echo Building target: $@
@echo Invoking: AVR/GNU Linker : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="wp_dc22_attiny88.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=attiny88 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny88"
@echo Finished building target: $@
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "wp_dc22_attiny88.elf" "wp_dc22_attiny88.hex"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "wp_dc22_attiny88.elf" "wp_dc22_attiny88.eep" || exit 0
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "wp_dc22_attiny88.elf" > "wp_dc22_attiny88.lss"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "wp_dc22_attiny88.elf" "wp_dc22_attiny88.srec"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "wp_dc22_attiny88.elf"
# Other Targets
clean:
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
-$(RM) $(C_DEPS_AS_ARGS)
rm -rf "wp_dc22_attiny88.elf" "wp_dc22_attiny88.a" "wp_dc22_attiny88.hex" "wp_dc22_attiny88.lss" "wp_dc22_attiny88.eep" "wp_dc22_attiny88.map" "wp_dc22_attiny88.srec" "wp_dc22_attiny88.usersignatures"

View File

@ -0,0 +1,10 @@
################################################################################
# Automatically-generated file. Do not edit or delete the file
################################################################################
src\adc.c
src\led.c
src\main.c

View File

@ -0,0 +1,41 @@
src/adc.d src/adc.o: ../src/adc.c ../src/adc.h ../src/config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h \
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h
../src/adc.h:
../src/config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h:
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h:

Binary file not shown.

View File

@ -0,0 +1,52 @@
src/led.d src/led.o: ../src/led.c ../src/led.h ../src/config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h \
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h \
../src/adc.h ../src/timer.h
../src/led.h:
../src/config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h:
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h:
../src/adc.h:
../src/timer.h:

Binary file not shown.

View File

@ -0,0 +1,72 @@
src/main.d src/main.o: ../src/main.c ../src/config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h \
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\eeprom.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stddef.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\pgmspace.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sleep.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h \
../src/i2c.h ../src/timer.h ../src/led.h ../src/adc.h \
../src/i2c_interrupt.h
../src/config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h:
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\eeprom.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stddef.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\pgmspace.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sleep.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h:
../src/i2c.h:
../src/timer.h:
../src/led.h:
../src/adc.h:
../src/i2c_interrupt.h:

Binary file not shown.

View File

@ -0,0 +1 @@
:00000001FF

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,643 @@
Archive member included to satisfy reference by file (symbol)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o (exit)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
src/led.o (__do_copy_data)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
src/adc.o (__do_clear_bss)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
src/main.o (eeprom_read_byte)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
src/main.o (eeprom_read_word)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
src/main.o (eeprom_write_word)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o) (eeprom_read_blraw)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o) (eeprom_write_byte)
Allocating common symbols
Common symbol size file
comm_timeout 0x1 src/main.o
adc_reread 0x1 src/adc.o
rgbled_pwm_rt 0x4 src/led.o
adc_result 0x12 src/adc.o
rgbled_pwm_lf 0x4 src/led.o
adc_busy 0x1 src/adc.o
rgbled_light_level 0x4 src/main.o
comm_data 0x4 src/main.o
adc_read_mode 0x1 src/adc.o
comm_data_idx 0x1 src/main.o
timer1_mode 0x1 src/led.o
Discarded input sections
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.text 0x00000000 0x0 src/adc.o
.data 0x00000000 0x0 src/adc.o
.bss 0x00000000 0x0 src/adc.o
.text 0x00000000 0x0 src/led.o
.data 0x00000000 0x0 src/led.o
.bss 0x00000000 0x0 src/led.o
.text 0x00000000 0x0 src/main.o
.data 0x00000000 0x0 src/main.o
.bss 0x00000000 0x0 src/main.o
.avr.prop 0x00000000 0x16 src/main.o
.text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.mul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.div
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.prologue
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.builtins
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.fmul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.fixed
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.mul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.div
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.prologue
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.builtins
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.fmul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.fixed
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.mul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.div
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.prologue
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.builtins
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.fmul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.fixed
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
Memory Configuration
Name Origin Length Attributes
text 0x00000000 0x00002000 xr
data 0x00800060 0x0000ffa0 rw !x
eeprom 0x00810000 0x00010000 rw !x
fuse 0x00820000 0x00000003 rw !x
lock 0x00830000 0x00000400 rw !x
signature 0x00840000 0x00000400 rw !x
user_signatures 0x00850000 0x00000400 rw !x
*default* 0x00000000 0xffffffff
Linker script and memory map
Address of section .data set to 0x800100
LOAD C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
LOAD src/adc.o
LOAD src/led.o
LOAD src/main.o
START GROUP
LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr25\libm.a
END GROUP
START GROUP
LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a
LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr25\libm.a
LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr25\libc.a
LOAD C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a
END GROUP
0x00002000 __TEXT_REGION_LENGTH__ = DEFINED (__TEXT_REGION_LENGTH__)?__TEXT_REGION_LENGTH__:0x2000
0x0000ffa0 __DATA_REGION_LENGTH__ = DEFINED (__DATA_REGION_LENGTH__)?__DATA_REGION_LENGTH__:0xffa0
0x00010000 __EEPROM_REGION_LENGTH__ = DEFINED (__EEPROM_REGION_LENGTH__)?__EEPROM_REGION_LENGTH__:0x10000
[0x00000003] __FUSE_REGION_LENGTH__ = DEFINED (__FUSE_REGION_LENGTH__)?__FUSE_REGION_LENGTH__:0x400
0x00000400 __LOCK_REGION_LENGTH__ = DEFINED (__LOCK_REGION_LENGTH__)?__LOCK_REGION_LENGTH__:0x400
0x00000400 __SIGNATURE_REGION_LENGTH__ = DEFINED (__SIGNATURE_REGION_LENGTH__)?__SIGNATURE_REGION_LENGTH__:0x400
0x00000400 __USER_SIGNATURE_REGION_LENGTH__ = DEFINED (__USER_SIGNATURE_REGION_LENGTH__)?__USER_SIGNATURE_REGION_LENGTH__:0x400
.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 0x00000000 0x8a8
*(.vectors)
.vectors 0x00000000 0x28 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
0x00000000 __vector_default
0x00000000 __vectors
*(.vectors)
*(.progmem.gcc*)
.progmem.gcc_sw_table.pegleg_cmd
0x00000028 0x34 src/main.o
0x0000005c . = ALIGN (0x2)
0x0000005c __trampolines_start = .
*(.trampolines)
.trampolines 0x0000005c 0x0 linker stubs
*(.trampolines*)
0x0000005c __trampolines_end = .
*libprintf_flt.a:*(.progmem.data)
*libc.a:*(.progmem.data)
*(.progmem*)
0x0000005c . = ALIGN (0x2)
*(.jumptables)
*(.jumptables*)
*(.lowtext)
*(.lowtext*)
0x0000005c __ctors_start = .
*(.ctors)
0x0000005c __ctors_end = .
0x0000005c __dtors_start = .
*(.dtors)
0x0000005c __dtors_end = .
SORT(*)(.ctors)
SORT(*)(.dtors)
*(.init0)
.init0 0x0000005c 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
0x0000005c __init
*(.init0)
*(.init1)
*(.init1)
*(.init2)
.init2 0x0000005c 0xc C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
*(.init2)
*(.init3)
*(.init3)
*(.init4)
.init4 0x00000068 0x16 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
0x00000068 __do_copy_data
.init4 0x0000007e 0x10 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
0x0000007e __do_clear_bss
*(.init4)
*(.init5)
*(.init5)
*(.init6)
*(.init6)
*(.init7)
*(.init7)
*(.init8)
*(.init8)
*(.init9)
.init9 0x0000008e 0x4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
*(.init9)
*(.text)
.text 0x00000092 0x2 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
0x00000092 __vector_1
0x00000092 __bad_interrupt
0x00000092 __vector_6
0x00000092 __vector_3
0x00000092 __vector_11
0x00000092 __vector_13
0x00000092 __vector_17
0x00000092 __vector_7
0x00000092 __vector_5
0x00000092 __vector_4
0x00000092 __vector_9
0x00000092 __vector_2
0x00000092 __vector_15
0x00000092 __vector_8
0x00000092 __vector_14
0x00000092 __vector_10
0x00000092 __vector_18
0x00000094 . = ALIGN (0x2)
*(.text.*)
.text.adc_init
0x00000094 0x24 src/adc.o
0x00000094 adc_init
.text.adc_channel
0x000000b8 0x44 src/adc.o
0x000000b8 adc_channel
.text.adc_start
0x000000fc 0x3c src/adc.o
0x000000fc adc_start
.text.__vector_16
0x00000138 0xba src/adc.o
0x00000138 __vector_16
.text.rgbled_io_init
0x000001f2 0x1a src/led.o
0x000001f2 rgbled_io_init
.text.rgbled_update
0x0000020c 0x7e src/led.o
0x0000020c rgbled_update
.text.rgbled_sensor_init
0x0000028a 0x60 src/led.o
0x0000028a rgbled_sensor_init
.text.rgbled_sensor_sensitivity
0x000002ea 0x14 src/led.o
0x000002ea rgbled_sensor_sensitivity
.text.rgbled_sensor_read_idx
0x000002fe 0x8 src/led.o
0x000002fe rgbled_sensor_read_idx
.text.rgbled_sensor_read
0x00000306 0x88 src/led.o
0x00000306 rgbled_sensor_read
.text.pegleg_cmd
0x0000038e 0x102 src/main.o
.text.i2c_slave_tx.constprop.4
0x00000490 0x18 src/main.o
.text.pegleg_data_tx
0x000004a8 0x70 src/main.o
.text.tempsensor_process
0x00000518 0x1a src/main.o
0x00000518 tempsensor_process
.text.tempsensor_read
0x00000532 0x38 src/main.o
0x00000532 tempsensor_read
.text.startup.main
0x0000056a 0x126 src/main.o
0x0000056a main
.text.__vector_19
0x00000690 0xde src/main.o
0x00000690 __vector_19
.text.__vector_12
0x0000076e 0xe4 src/main.o
0x0000076e __vector_12
.text.avr-libc
0x00000852 0xe C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
0x00000852 eeprom_read_byte
.text.avr-libc
0x00000860 0x8 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
0x00000860 eeprom_read_word
.text.avr-libc
0x00000868 0x6 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
0x00000868 eeprom_write_word
.text.avr-libc
0x0000086e 0x1c C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
0x0000086e eeprom_read_block
0x00000872 eeprom_read_blraw
.text.avr-libc
0x0000088a 0x1a C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
0x0000088a eeprom_write_byte
0x0000088c eeprom_write_r18
0x000008a4 . = ALIGN (0x2)
*(.fini9)
.fini9 0x000008a4 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
0x000008a4 _exit
0x000008a4 exit
*(.fini9)
*(.fini8)
*(.fini8)
*(.fini7)
*(.fini7)
*(.fini6)
*(.fini6)
*(.fini5)
*(.fini5)
*(.fini4)
*(.fini4)
*(.fini3)
*(.fini3)
*(.fini2)
*(.fini2)
*(.fini1)
*(.fini1)
*(.fini0)
.fini0 0x000008a4 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
*(.fini0)
0x000008a8 _etext = .
.data 0x00800100 0x4 load address 0x000008a8
0x00800100 PROVIDE (__data_start, .)
*(.data)
*(.data*)
.data.rgbled_sensitivity
0x00800100 0x4 src/led.o
*(.gnu.linkonce.d*)
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.r*)
0x00800104 . = ALIGN (0x2)
0x00800104 _edata = .
0x00800104 PROVIDE (__data_end, .)
.bss 0x00800104 0x30
0x00800104 PROVIDE (__bss_start, .)
*(.bss)
*(.bss*)
.bss.adc_averages
0x00800104 0x1 src/adc.o
.bss.rgbled_read_sel
0x00800105 0x1 src/led.o
.bss.temp_offset
0x00800106 0x2 src/main.o
.bss.temperature
0x00800108 0x1 src/main.o
.bss.pirate_sleep_mode
0x00800109 0x1 src/main.o
.bss.tim0_centi
0x0080010a 0x1 src/main.o
.bss.tim0_milli
0x0080010b 0x1 src/main.o
*(COMMON)
COMMON 0x0080010c 0x15 src/adc.o
0x0080010c adc_reread
0x0080010d adc_result
0x0080011f adc_busy
0x00800120 adc_read_mode
COMMON 0x00800121 0x9 src/led.o
0x00800121 rgbled_pwm_rt
0x00800125 rgbled_pwm_lf
0x00800129 timer1_mode
COMMON 0x0080012a 0xa src/main.o
0x0080012a comm_timeout
0x0080012b rgbled_light_level
0x0080012f comm_data
0x00800133 comm_data_idx
0x00800134 PROVIDE (__bss_end, .)
0x000008a8 __data_load_start = LOADADDR (.data)
0x000008ac __data_load_end = (__data_load_start + SIZEOF (.data))
.noinit 0x00800134 0x0
[!provide] PROVIDE (__noinit_start, .)
*(.noinit*)
[!provide] PROVIDE (__noinit_end, .)
0x00800134 _end = .
[!provide] PROVIDE (__heap_start, .)
.eeprom 0x00810000 0x0
*(.eeprom*)
0x00810000 __eeprom_end = .
.fuse
*(.fuse)
*(.lfuse)
*(.hfuse)
*(.efuse)
.lock
*(.lock*)
.signature
*(.signature*)
.user_signatures
*(.user_signatures*)
.stab
*(.stab)
.stabstr
*(.stabstr)
.stab.excl
*(.stab.excl)
.stab.exclstr
*(.stab.exclstr)
.stab.index
*(.stab.index)
.stab.indexstr
*(.stab.indexstr)
.comment 0x00000000 0x30
*(.comment)
.comment 0x00000000 0x30 src/adc.o
0x31 (size before relaxing)
.comment 0x00000030 0x31 src/led.o
.comment 0x00000030 0x31 src/main.o
.note.gnu.avr.deviceinfo
0x00000000 0x3c
.note.gnu.avr.deviceinfo
0x00000000 0x3c C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.note.gnu.build-id
*(.note.gnu.build-id)
.debug
*(.debug)
.line
*(.line)
.debug_srcinfo
*(.debug_srcinfo)
.debug_sfnames
*(.debug_sfnames)
.debug_aranges 0x00000000 0x178
*(.debug_aranges)
.debug_aranges
0x00000000 0x38 src/adc.o
.debug_aranges
0x00000038 0x48 src/led.o
.debug_aranges
0x00000080 0x58 src/main.o
.debug_aranges
0x000000d8 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.debug_aranges
0x000000f8 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.debug_aranges
0x00000118 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.debug_aranges
0x00000138 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.debug_aranges
0x00000158 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.debug_pubnames
*(.debug_pubnames)
.debug_info 0x00000000 0x1493
*(.debug_info .gnu.linkonce.wi.*)
.debug_info 0x00000000 0x576 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.debug_info 0x00000576 0x1b6 src/adc.o
.debug_info 0x0000072c 0x360 src/led.o
.debug_info 0x00000a8c 0x6af src/main.o
.debug_info 0x0000113b 0xab C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.debug_info 0x000011e6 0xab C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.debug_info 0x00001291 0xab C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.debug_info 0x0000133c 0xac C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.debug_info 0x000013e8 0xab C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.debug_abbrev 0x00000000 0xb12
*(.debug_abbrev)
.debug_abbrev 0x00000000 0x52b C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.debug_abbrev 0x0000052b 0x105 src/adc.o
.debug_abbrev 0x00000630 0x1f6 src/led.o
.debug_abbrev 0x00000826 0x288 src/main.o
.debug_abbrev 0x00000aae 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.debug_abbrev 0x00000ac2 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.debug_abbrev 0x00000ad6 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.debug_abbrev 0x00000aea 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.debug_abbrev 0x00000afe 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.debug_line 0x00000000 0xe6a
*(.debug_line .debug_line.* .debug_line_end)
.debug_line 0x00000000 0x10f C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.debug_line 0x0000010f 0x1d0 src/adc.o
.debug_line 0x000002df 0x2bb src/led.o
.debug_line 0x0000059a 0x669 src/main.o
.debug_line 0x00000c03 0x74 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.debug_line 0x00000c77 0x61 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.debug_line 0x00000cd8 0x5b C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.debug_line 0x00000d33 0x9f C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.debug_line 0x00000dd2 0x98 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.debug_frame 0x00000000 0x230
*(.debug_frame)
.debug_frame 0x00000000 0x8c src/adc.o
.debug_frame 0x0000008c 0x80 src/led.o
.debug_frame 0x0000010c 0x124 src/main.o
.debug_str 0x00000000 0x6f2
*(.debug_str)
.debug_str 0x00000000 0x1d9 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.debug_str 0x000001d9 0x1eb src/adc.o
0x22e (size before relaxing)
.debug_str 0x000003c4 0x14b src/led.o
0x326 (size before relaxing)
.debug_str 0x0000050f 0x1e3 src/main.o
0x4a4 (size before relaxing)
.debug_loc 0x00000000 0x4a9
*(.debug_loc)
.debug_loc 0x00000000 0xf6 src/adc.o
.debug_loc 0x000000f6 0xf3 src/led.o
.debug_loc 0x000001e9 0x2c0 src/main.o
.debug_macinfo
*(.debug_macinfo)
.debug_weaknames
*(.debug_weaknames)
.debug_funcnames
*(.debug_funcnames)
.debug_typenames
*(.debug_typenames)
.debug_varnames
*(.debug_varnames)
.debug_pubtypes
*(.debug_pubtypes)
.debug_ranges 0x00000000 0xa8
*(.debug_ranges)
.debug_ranges 0x00000000 0x28 src/adc.o
.debug_ranges 0x00000028 0x38 src/led.o
.debug_ranges 0x00000060 0x48 src/main.o
.debug_macro
*(.debug_macro)
OUTPUT(wp_dc22_attiny88.elf elf32-avr)
LOAD linker stubs

View File

@ -0,0 +1,142 @@
S018000077705F646332325F617474696E7938382E7372656333
S11300002DC047C046C045C044C043C042C041C0E3
S113001040C03FC03EC03DC0AAC33BC03AC039C087
S11300208BC037C036C034C3BDC1C0C1CAC1DBC177
S1130030F8C116C228C227C2F9C103C224C223C20E
S113004022C221C220C209C20BC20AC21CC21BC2E4
S11300501AC219C218C217C216C207C211241FBE7F
S1130060CFEFD2E0DEBFCDBF11E0A0E0B1E0E8EA1F
S1130070F8E002C005900D92A430B107D9F721E051
S1130080A4E0B1E001C01D92A433B207E1F76DD240
S113009009C4B6CFE4E6F0E080818E7F8083EAE78E
S11300A0F0E08FED8083ACE7B0E08C918F7D8C9392
S11300B08081886880830895282F803188F4909106
S11300C07C00907F982B90937C00883030F481E002
S11300D001C0880F2A95EAF701C080E080937E0072
S11300E0613021F480917C00806405C0623029F481
S11300F080917C008F7B80937C00089590917A009E
S1130100292F207496FD15C080930C01662311F0ED
S1130110982F01C090E09093040190917C009F700F
S1130120906890931F0190917A00906490937A0064
S113013001C021E0822F08951F920F920FB60F92F3
S113014011242F934F935F938F939F93AF93BF93F8
S1130150EF93FF93E0917C00EF7020910401222340
S1130160D1F080910C012817B1F0E930A0F4AE2F42
S1130170B0E0AA0FBB1FA35FBE4F4D915C911197D6
S11301808091780090917900840F951F96958795BA
S113019011969C938E9380910C01882359F0809141
S11301A00C01815080930C0180917A0080648093CB
S11301B07A0011C021110DC0E93058F4F0E08091AB
S11301C0780090917900EE0FFF1FE35FFE4F91835B
S11301D0808310921F01FF91EF91BF91AF919F9186
S11301E08F915F914F912F910F900FBE0F901F90A1
S11301F018958AB1806F8AB987B18F6087B98BB13E
S1130200806F8BB988B18F6088B90895CF93DF93DD
S11302108BB1806F8BB988B18F6088B9C8E8D0E0A2
S11302208EEF8883AAE8B0E08C938AEF90E09093F5
S11302308500809384003BB124E02D0D81E090E0A3
S1130240AC0101C0440F2A95EAF7242F20952323FB
S11302502BB928B10D2C01C0880F0A94EAF78095B8
S1130260822388B9ED2DF0E0EB5DFE4F8BEF90819A
S1130270282F291B2883ED2DF0E0EF5DFE4F9081A0
S1130280891B8C93DF91CF9108959BB1906F9BB99B
S1130290E0E8F0E090819F70908397B1907F97B9E8
S11302A095B7906195BF47B121E030E0B90102C034
S11302B0660F771F8A95E2F7CB01462B47B998B1B1
S11302C0907F98B92A9A98B1982B98B92A9878E08F
S11302D07A95F1F797B18095982397B998B18923C6
S11302E088B985B78F7E85BF0895843038F4662336
S11302F029F0E82FF0E0E050FF4F60830895837009
S113030080930501089580910501E82FF0E0E05005
S1130310FF4F9081911101C091E02E2DE11003C097
S113032061E08FE012C0213019F460E080E018C071
S1130330223061F490911F01992319F0EE24E39483
S11303400895A3DF6FEF80910501B6CE4E2D50E0E6
S1130350892F90E002964817590719F461E083E069
S1130360CDCE8417950794F42150E22E80911F017D
S113037081110CC06FEF8FE09FDE3BDF8EEF809327
S1130380800084B1866084B91092200108958F2D75
S11303904F2D50E04A31510508F075C0FA01EC5E6A
S11303A0FF4F0994F12C10922A0108958091330192
S11303B0882309F46CC0F090300183E0809333010A
S11303C050C0E0912F01E43020F4F0E0EB5DFE4FEB
S11303D006C0E83008F044C0F0E0E35EFE4F8091D0
S11303E0300180833DC080913301882309F44FC0DC
S11303F080911D0190911E01892B09F444C06091E4
S11304001D0170911E0180913001681B710987FDE7
S1130410739570930701609306018EE390E024D2F4
S11304201FC0809133018230D8F41DC08091200117
S1130430811117C010922001E12C88E080932001E3
S113044010C08091200181110CC010922001E12C78
S113045080912F0154DF81E0F1CF84E08093090182
S1130460F12C10922A0180E00895809133018823B1
S113047071F080912F01843098F7609130016623E8
S113048079F333DFEDCFF12C10922A0181E0089546
S11304908093BB00ECEBF0E08081806880838081F6
S11304A08F7B808380E008958F2D8830B9F0893068
S11304B0C1F0843051F580912F01803428F490E00C
S11304C0C8D1E6DF81E006C08091BC008F7B8093B9
S11304D0BC008FEFF12C10922A010895809108013D
S11304E00EC0E0912F01E370F0E0EE0FFF1FE35F19
S11304F0FE4F808191819695879596958795C8DF63
S1130500F12C10922A0181E008958091BC008F7B28
S11305108093BC008FEF089580911D0190911E017E
S113052090910601891B982F959595959595891B12
S113053008958E2DE11003C062E088E0BDCD8330C4
S113054019F461E084E0DACD843070F08150E82E53
S113055080911F01811108C061E08FE0ADDD109230
S11305602001DADF80930801089580E88093610018
S11305701092610082B3806F82BB1DB881E084B9A0
S113058017B81AB8CFEFCEB9DEEFD5B9C8B9CBB921
S113059030DE22E02093B8008CEF8093B90086EE21
S11305A08093BA001092BD0085E48093BC008091D2
S11305B064008A7F809364009BEF95BD8DE387BDC3
S11305C016BC20936E00809164008C7F809364003D
S11305D0C0938900C0938800C0938A00109285005C
S11305E010928400D093800089E18093810010925E
S11305F0820080918000809329019093860084B1C9
S1130600866084B910926F0045DD629923C042DD93
S11306102FEF80E792E0215080409040E1F700C046
S11306200000629917C0789488E08093200181DFEC
S113063080911F018111FCCF60911D0170911E01F9
S113064070930701609306018EE390E00DD1109240
S113065020010DC08EE390E003D1813322E09207A4
S113066014F081E191E0909307018093060183B730
S1130670897F90910901892B83BF10920901789495
S113068083B7816083BF889583B78E7F83BFEFCFA5
S11306901F920F920FB60F9211242F933F934F93F3
S11306A05F936F937F938F939F93AF93BF93EF93D6
S11306B0FF938091B900887F803AF1F160F4883625
S11306C009F43FC028F4882391F18036D1F134C075
S11306D0803839F031C0883B41F170F5883A29F10E
S11306E02BC08091BB00F1100FC0982F92959F7082
S11306F0F92E982F9F7090932F011092330110922E
S11307002A0187FF1EC00AC0E0913301EF5FE37046
S1130710E0933301F0E0E15DFE4F808338DE88230F
S113072081F08091BC008F7B0AC0BEDE0AC080913C
S1130730BC0080698093BC008091BC00806480937D
S1130740BC008091BC0080688093BC00FF91EF9155
S1130750BF91AF919F918F917F916F915F914F91D5
S11307603F912F910F900FBE0F901F9018951F92DD
S11307700F920FB60F9211242F933F934F935F93D1
S11307806F937F938F939F93AF93BF93EF93FF9355
S113079080910B018F5F883C18F480930B010CC08F
S11307A010920B0180910A018F5F843618F48093B4
S11307B00A0102C010920A0187B58D3311F08DE34E
S11307C001C08EE387BD80912001882371F0809160
S11307D02001813021F0883019F4ABDE01C093DDB3
S11307E08E2D8F3F11F08F5FE82E80912001813094
S11307F041F081E08D0D833010F4D82E01C0D12C4E
S113080005DDFF20A1F080912A018F5F80932A01EA
S1130810823368F0F12C10922A018091BC008F7B06
S11308208093BC008091BC0080648093BC0086B53A
S1130830FF91EF91BF91AF919F918F917F916F91B4
S11308405F914F913F912F910F900FBE0F901F908A
S11308501895F999FECF81BDF89A992780B5089526
S1130860A8E1B0E042E005C010D0272F0FC0DC01A2
S1130870862FE82FF999FECF05C0E1BDF89AE395DC
S113088000B40D924150C8F70895262FF999FECF70
S11308901FBA81BD20BD0FB6F894FA9AF99A0FBE1B
S10B08A001960895F894FFCFBE
S10708A80101010144
S9030000FC

View File

@ -0,0 +1,152 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
SHELL := cmd.exe
RM := rm -rf
USER_OBJS :=
LIBS :=
PROJ :=
O_SRCS :=
C_SRCS :=
S_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
PREPROCESSING_SRCS :=
OBJS :=
OBJS_AS_ARGS :=
C_DEPS :=
C_DEPS_AS_ARGS :=
EXECUTABLES :=
OUTPUT_FILE_PATH :=
OUTPUT_FILE_PATH_AS_ARGS :=
AVR_APP_PATH :=$$$AVR_APP_PATH$$$
QUOTE := "
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:=
LIB_DEP:=
LINKER_SCRIPT_DEP:=
# Every subdirectory with source files must be described here
SUBDIRS := \
../src
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/adc.c \
../src/led.c \
../src/main.c
PREPROCESSING_SRCS +=
ASM_SRCS +=
OBJS += \
src/adc.o \
src/led.o \
src/main.o
OBJS_AS_ARGS += \
src/adc.o \
src/led.o \
src/main.o
C_DEPS += \
src/adc.d \
src/led.d \
src/main.d
C_DEPS_AS_ARGS += \
src/adc.d \
src/led.d \
src/main.d
OUTPUT_FILE_PATH +=wp_dc22_attiny88.elf
OUTPUT_FILE_PATH_AS_ARGS +=wp_dc22_attiny88.elf
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:= ./makedep.mk
LIB_DEP+=
LINKER_SCRIPT_DEP+=
# AVR32/GNU C Compiler
src/adc.o: ../src/adc.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DNDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include" -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -mmcu=attiny88 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny88" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
src/led.o: ../src/led.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DNDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include" -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -mmcu=attiny88 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny88" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
src/main.o: ../src/main.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DNDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include" -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -mmcu=attiny88 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny88" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
# AVR32/GNU Preprocessing Assembler
# AVR32/GNU Assembler
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)
$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
@echo Building target: $@
@echo Invoking: AVR/GNU Linker : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="wp_dc22_attiny88.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=attiny88 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny88"
@echo Finished building target: $@
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "wp_dc22_attiny88.elf" "wp_dc22_attiny88.hex"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "wp_dc22_attiny88.elf" "wp_dc22_attiny88.eep" || exit 0
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "wp_dc22_attiny88.elf" > "wp_dc22_attiny88.lss"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "wp_dc22_attiny88.elf" "wp_dc22_attiny88.srec"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "wp_dc22_attiny88.elf"
# Other Targets
clean:
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
-$(RM) $(C_DEPS_AS_ARGS)
rm -rf "wp_dc22_attiny88.elf" "wp_dc22_attiny88.a" "wp_dc22_attiny88.hex" "wp_dc22_attiny88.lss" "wp_dc22_attiny88.eep" "wp_dc22_attiny88.map" "wp_dc22_attiny88.srec" "wp_dc22_attiny88.usersignatures"

View File

@ -0,0 +1,10 @@
################################################################################
# Automatically-generated file. Do not edit or delete the file
################################################################################
src\adc.c
src\led.c
src\main.c

View File

@ -0,0 +1,41 @@
src/adc.d src/adc.o: ../src/adc.c ../src/adc.h ../src/config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h \
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h
../src/adc.h:
../src/config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h:
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h:

Binary file not shown.

View File

@ -0,0 +1,52 @@
src/led.d src/led.o: ../src/led.c ../src/led.h ../src/config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h \
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h \
../src/adc.h ../src/timer.h
../src/led.h:
../src/config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h:
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h:
../src/adc.h:
../src/timer.h:

Binary file not shown.

View File

@ -0,0 +1,72 @@
src/main.d src/main.o: ../src/main.c ../src/config.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h \
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\eeprom.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stddef.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\pgmspace.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sleep.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h \
../src/i2c.h ../src/timer.h ../src/led.h ../src/adc.h \
../src/i2c_interrupt.h
../src/config.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h:
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include/avr/iotn88.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\eeprom.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stddef.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\pgmspace.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sleep.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h:
../src/i2c.h:
../src/timer.h:
../src/led.h:
../src/adc.h:
../src/i2c_interrupt.h:

Binary file not shown.

View File

@ -0,0 +1 @@
:00000001FF

Binary file not shown.

View File

@ -0,0 +1,141 @@
:100000002DC047C046C045C044C043C042C041C0E7
:1000100040C03FC03EC03DC0AAC33BC03AC039C08B
:100020008BC037C036C034C3BDC1C0C1CAC1DBC17B
:10003000F8C116C228C227C2F9C103C224C223C212
:1000400022C221C220C209C20BC20AC21CC21BC2E8
:100050001AC219C218C217C216C207C211241FBE83
:10006000CFEFD2E0DEBFCDBF11E0A0E0B1E0E8EA23
:10007000F8E002C005900D92A430B107D9F721E055
:10008000A4E0B1E001C01D92A433B207E1F76DD244
:1000900009C4B6CFE4E6F0E080818E7F8083EAE792
:1000A000F0E08FED8083ACE7B0E08C918F7D8C9396
:1000B0008081886880830895282F803188F490910A
:1000C0007C00907F982B90937C00883030F481E006
:1000D00001C0880F2A95EAF701C080E080937E0076
:1000E000613021F480917C00806405C0623029F485
:1000F00080917C008F7B80937C00089590917A00A2
:10010000292F207496FD15C080930C01662311F0F1
:10011000982F01C090E09093040190917C009F7013
:10012000906890931F0190917A00906490937A0068
:1001300001C021E0822F08951F920F920FB60F92F7
:1001400011242F934F935F938F939F93AF93BF93FC
:10015000EF93FF93E0917C00EF7020910401222344
:10016000D1F080910C012817B1F0E930A0F4AE2F46
:10017000B0E0AA0FBB1FA35FBE4F4D915C911197DA
:100180008091780090917900840F951F96958795BE
:1001900011969C938E9380910C01882359F0809145
:1001A0000C01815080930C0180917A0080648093CF
:1001B0007A0011C021110DC0E93058F4F0E08091AF
:1001C000780090917900EE0FFF1FE35FFE4F91835F
:1001D000808310921F01FF91EF91BF91AF919F918A
:1001E0008F915F914F912F910F900FBE0F901F90A5
:1001F00018958AB1806F8AB987B18F6087B98BB142
:10020000806F8BB988B18F6088B90895CF93DF93E1
:100210008BB1806F8BB988B18F6088B9C8E8D0E0A6
:100220008EEF8883AAE8B0E08C938AEF90E09093F9
:100230008500809384003BB124E02D0D81E090E0A7
:10024000AC0101C0440F2A95EAF7242F20952323FF
:100250002BB928B10D2C01C0880F0A94EAF78095BC
:10026000822388B9ED2DF0E0EB5DFE4F8BEF90819E
:10027000282F291B2883ED2DF0E0EF5DFE4F9081A4
:10028000891B8C93DF91CF9108959BB1906F9BB99F
:10029000E0E8F0E090819F70908397B1907F97B9EC
:1002A00095B7906195BF47B121E030E0B90102C038
:1002B000660F771F8A95E2F7CB01462B47B998B1B5
:1002C000907F98B92A9A98B1982B98B92A9878E093
:1002D0007A95F1F797B18095982397B998B18923CA
:1002E00088B985B78F7E85BF0895843038F466233A
:1002F00029F0E82FF0E0E050FF4F6083089583700D
:1003000080930501089580910501E82FF0E0E05009
:10031000FF4F9081911101C091E02E2DE11003C09B
:1003200061E08FE012C0213019F460E080E018C075
:10033000223061F490911F01992319F0EE24E39487
:100340000895A3DF6FEF80910501B6CE4E2D50E0EA
:10035000892F90E002964817590719F461E083E06D
:10036000CDCE8417950794F42150E22E80911F0181
:1003700081110CC06FEF8FE09FDE3BDF8EEF80932B
:10038000800084B1866084B91092200108958F2D79
:100390004F2D50E04A31510508F075C0FA01EC5E6E
:1003A000FF4F0994F12C10922A0108958091330196
:1003B000882309F46CC0F090300183E0809333010E
:1003C00050C0E0912F01E43020F4F0E0EB5DFE4FEF
:1003D00006C0E83008F044C0F0E0E35EFE4F8091D4
:1003E000300180833DC080913301882309F44FC0E0
:1003F00080911D0190911E01892B09F444C06091E8
:100400001D0170911E0180913001681B710987FDEB
:10041000739570930701609306018EE390E024D2F8
:100420001FC0809133018230D8F41DC0809120011B
:10043000811117C010922001E12C88E080932001E7
:1004400010C08091200181110CC010922001E12C7C
:1004500080912F0154DF81E0F1CF84E08093090186
:10046000F12C10922A0180E00895809133018823B5
:1004700071F080912F01843098F7609130016623EC
:1004800079F333DFEDCFF12C10922A0181E008954A
:100490008093BB00ECEBF0E08081806880838081FA
:1004A0008F7B808380E008958F2D8830B9F089306C
:1004B000C1F0843051F580912F01803428F490E010
:1004C000C8D1E6DF81E006C08091BC008F7B8093BD
:1004D000BC008FEFF12C10922A0108958091080141
:1004E0000EC0E0912F01E370F0E0EE0FFF1FE35F1D
:1004F000FE4F808191819695879596958795C8DF67
:10050000F12C10922A0181E008958091BC008F7B2C
:100510008093BC008FEF089580911D0190911E0182
:1005200090910601891B982F959595959595891B16
:1005300008958E2DE11003C062E088E0BDCD8330C8
:1005400019F461E084E0DACD843070F08150E82E57
:1005500080911F01811108C061E08FE0ADDD109234
:100560002001DADF80930801089580E8809361001C
:100570001092610082B3806F82BB1DB881E084B9A4
:1005800017B81AB8CFEFCEB9DEEFD5B9C8B9CBB925
:1005900030DE22E02093B8008CEF8093B90086EE25
:1005A0008093BA001092BD0085E48093BC008091D6
:1005B00064008A7F809364009BEF95BD8DE387BDC7
:1005C00016BC20936E00809164008C7F8093640041
:1005D000C0938900C0938800C0938A001092850060
:1005E00010928400D093800089E180938100109262
:1005F000820080918000809329019093860084B1CD
:10060000866084B910926F0045DD629923C042DD97
:100610002FEF80E792E0215080409040E1F700C04A
:100620000000629917C0789488E08093200181DFF0
:1006300080911F018111FCCF60911D0170911E01FD
:1006400070930701609306018EE390E00DD1109244
:1006500020010DC08EE390E003D1813322E09207A8
:1006600014F081E191E0909307018093060183B734
:10067000897F90910901892B83BF10920901789499
:1006800083B7816083BF889583B78E7F83BFEFCFA9
:100690001F920F920FB60F9211242F933F934F93F7
:1006A0005F936F937F938F939F93AF93BF93EF93DA
:1006B000FF938091B900887F803AF1F160F4883629
:1006C00009F43FC028F4882391F18036D1F134C079
:1006D000803839F031C0883B41F170F5883A29F112
:1006E0002BC08091BB00F1100FC0982F92959F7086
:1006F000F92E982F9F7090932F0110923301109232
:100700002A0187FF1EC00AC0E0913301EF5FE3704A
:10071000E0933301F0E0E15DFE4F808338DE882313
:1007200081F08091BC008F7B0AC0BEDE0AC0809140
:10073000BC0080698093BC008091BC008064809381
:10074000BC008091BC0080688093BC00FF91EF9159
:10075000BF91AF919F918F917F916F915F914F91D9
:100760003F912F910F900FBE0F901F9018951F92E1
:100770000F920FB60F9211242F933F934F935F93D5
:100780006F937F938F939F93AF93BF93EF93FF9359
:1007900080910B018F5F883C18F480930B010CC093
:1007A00010920B0180910A018F5F843618F48093B8
:1007B0000A0102C010920A0187B58D3311F08DE352
:1007C00001C08EE387BD80912001882371F0809164
:1007D0002001813021F0883019F4ABDE01C093DDB7
:1007E0008E2D8F3F11F08F5FE82E80912001813098
:1007F00041F081E08D0D833010F4D82E01C0D12C52
:1008000005DDFF20A1F080912A018F5F80932A01EE
:10081000823368F0F12C10922A018091BC008F7B0A
:100820008093BC008091BC0080648093BC0086B53E
:10083000FF91EF91BF91AF919F918F917F916F91B8
:100840005F914F913F912F910F900FBE0F901F908E
:100850001895F999FECF81BDF89A992780B508952A
:10086000A8E1B0E042E005C010D0272F0FC0DC01A6
:10087000862FE82FF999FECF05C0E1BDF89AE395E0
:1008800000B40D924150C8F70895262FF999FECF74
:100890001FBA81BD20BD0FB6F894FA9AF99A0FBE1F
:0808A00001960895F894FFCFC2
:0408A8000101010148
:00000001FF

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,613 @@
Archive member included to satisfy reference by file (symbol)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o (exit)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
src/led.o (__do_copy_data)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
src/adc.o (__do_clear_bss)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
src/main.o (eeprom_read_byte)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
src/main.o (eeprom_read_word)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
src/main.o (eeprom_write_word)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o) (eeprom_read_blraw)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o) (eeprom_write_byte)
Allocating common symbols
Common symbol size file
comm_timeout 0x1 src/main.o
adc_reread 0x1 src/adc.o
rgbled_pwm_rt 0x4 src/led.o
adc_result 0x12 src/adc.o
rgbled_pwm_lf 0x4 src/led.o
adc_busy 0x1 src/adc.o
rgbled_light_level 0x4 src/main.o
comm_data 0x4 src/main.o
adc_read_mode 0x1 src/adc.o
comm_data_idx 0x1 src/main.o
timer1_mode 0x1 src/led.o
Discarded input sections
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.text 0x00000000 0x0 src/adc.o
.data 0x00000000 0x0 src/adc.o
.bss 0x00000000 0x0 src/adc.o
.text 0x00000000 0x0 src/led.o
.data 0x00000000 0x0 src/led.o
.bss 0x00000000 0x0 src/led.o
.text 0x00000000 0x0 src/main.o
.data 0x00000000 0x0 src/main.o
.bss 0x00000000 0x0 src/main.o
.avr.prop 0x00000000 0x16 src/main.o
.text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.mul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.div
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.prologue
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.builtins
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.fmul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text.libgcc.fixed
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
.text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.mul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.div
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.prologue
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.builtins
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.fmul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text.libgcc.fixed
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
.text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.mul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.div
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.prologue
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.builtins
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.fmul
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text.libgcc.fixed
0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.text 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
Memory Configuration
Name Origin Length Attributes
text 0x00000000 0x00002000 xr
data 0x00800060 0x0000ffa0 rw !x
eeprom 0x00810000 0x00010000 rw !x
fuse 0x00820000 0x00000003 rw !x
lock 0x00830000 0x00000400 rw !x
signature 0x00840000 0x00000400 rw !x
user_signatures 0x00850000 0x00000400 rw !x
*default* 0x00000000 0xffffffff
Linker script and memory map
Address of section .data set to 0x800100
LOAD C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
LOAD src/adc.o
LOAD src/led.o
LOAD src/main.o
START GROUP
LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr25\libm.a
END GROUP
START GROUP
LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a
LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr25\libm.a
LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr25\libc.a
LOAD C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a
END GROUP
0x00002000 __TEXT_REGION_LENGTH__ = DEFINED (__TEXT_REGION_LENGTH__)?__TEXT_REGION_LENGTH__:0x2000
0x0000ffa0 __DATA_REGION_LENGTH__ = DEFINED (__DATA_REGION_LENGTH__)?__DATA_REGION_LENGTH__:0xffa0
0x00010000 __EEPROM_REGION_LENGTH__ = DEFINED (__EEPROM_REGION_LENGTH__)?__EEPROM_REGION_LENGTH__:0x10000
[0x00000003] __FUSE_REGION_LENGTH__ = DEFINED (__FUSE_REGION_LENGTH__)?__FUSE_REGION_LENGTH__:0x400
0x00000400 __LOCK_REGION_LENGTH__ = DEFINED (__LOCK_REGION_LENGTH__)?__LOCK_REGION_LENGTH__:0x400
0x00000400 __SIGNATURE_REGION_LENGTH__ = DEFINED (__SIGNATURE_REGION_LENGTH__)?__SIGNATURE_REGION_LENGTH__:0x400
0x00000400 __USER_SIGNATURE_REGION_LENGTH__ = DEFINED (__USER_SIGNATURE_REGION_LENGTH__)?__USER_SIGNATURE_REGION_LENGTH__:0x400
.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 0x00000000 0x8a8
*(.vectors)
.vectors 0x00000000 0x28 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
0x00000000 __vector_default
0x00000000 __vectors
*(.vectors)
*(.progmem.gcc*)
.progmem.gcc_sw_table.pegleg_cmd
0x00000028 0x34 src/main.o
0x0000005c . = ALIGN (0x2)
0x0000005c __trampolines_start = .
*(.trampolines)
.trampolines 0x0000005c 0x0 linker stubs
*(.trampolines*)
0x0000005c __trampolines_end = .
*libprintf_flt.a:*(.progmem.data)
*libc.a:*(.progmem.data)
*(.progmem*)
0x0000005c . = ALIGN (0x2)
*(.jumptables)
*(.jumptables*)
*(.lowtext)
*(.lowtext*)
0x0000005c __ctors_start = .
*(.ctors)
0x0000005c __ctors_end = .
0x0000005c __dtors_start = .
*(.dtors)
0x0000005c __dtors_end = .
SORT(*)(.ctors)
SORT(*)(.dtors)
*(.init0)
.init0 0x0000005c 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
0x0000005c __init
*(.init0)
*(.init1)
*(.init1)
*(.init2)
.init2 0x0000005c 0xc C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
*(.init2)
*(.init3)
*(.init3)
*(.init4)
.init4 0x00000068 0x16 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_copy_data.o)
0x00000068 __do_copy_data
.init4 0x0000007e 0x10 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_clear_bss.o)
0x0000007e __do_clear_bss
*(.init4)
*(.init5)
*(.init5)
*(.init6)
*(.init6)
*(.init7)
*(.init7)
*(.init8)
*(.init8)
*(.init9)
.init9 0x0000008e 0x4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
*(.init9)
*(.text)
.text 0x00000092 0x2 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
0x00000092 __vector_1
0x00000092 __bad_interrupt
0x00000092 __vector_6
0x00000092 __vector_3
0x00000092 __vector_11
0x00000092 __vector_13
0x00000092 __vector_17
0x00000092 __vector_7
0x00000092 __vector_5
0x00000092 __vector_4
0x00000092 __vector_9
0x00000092 __vector_2
0x00000092 __vector_15
0x00000092 __vector_8
0x00000092 __vector_14
0x00000092 __vector_10
0x00000092 __vector_18
0x00000094 . = ALIGN (0x2)
*(.text.*)
.text.adc_init
0x00000094 0x24 src/adc.o
0x00000094 adc_init
.text.adc_channel
0x000000b8 0x44 src/adc.o
0x000000b8 adc_channel
.text.adc_start
0x000000fc 0x3c src/adc.o
0x000000fc adc_start
.text.__vector_16
0x00000138 0xba src/adc.o
0x00000138 __vector_16
.text.rgbled_io_init
0x000001f2 0x1a src/led.o
0x000001f2 rgbled_io_init
.text.rgbled_update
0x0000020c 0x7e src/led.o
0x0000020c rgbled_update
.text.rgbled_sensor_init
0x0000028a 0x60 src/led.o
0x0000028a rgbled_sensor_init
.text.rgbled_sensor_sensitivity
0x000002ea 0x14 src/led.o
0x000002ea rgbled_sensor_sensitivity
.text.rgbled_sensor_read_idx
0x000002fe 0x8 src/led.o
0x000002fe rgbled_sensor_read_idx
.text.rgbled_sensor_read
0x00000306 0x88 src/led.o
0x00000306 rgbled_sensor_read
.text.pegleg_cmd
0x0000038e 0x102 src/main.o
.text.i2c_slave_tx.constprop.4
0x00000490 0x18 src/main.o
.text.pegleg_data_tx
0x000004a8 0x70 src/main.o
.text.tempsensor_process
0x00000518 0x1a src/main.o
0x00000518 tempsensor_process
.text.tempsensor_read
0x00000532 0x38 src/main.o
0x00000532 tempsensor_read
.text.startup.main
0x0000056a 0x126 src/main.o
0x0000056a main
.text.__vector_19
0x00000690 0xde src/main.o
0x00000690 __vector_19
.text.__vector_12
0x0000076e 0xe4 src/main.o
0x0000076e __vector_12
.text.avr-libc
0x00000852 0xe C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
0x00000852 eeprom_read_byte
.text.avr-libc
0x00000860 0x8 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
0x00000860 eeprom_read_word
.text.avr-libc
0x00000868 0x6 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
0x00000868 eeprom_write_word
.text.avr-libc
0x0000086e 0x1c C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
0x0000086e eeprom_read_block
0x00000872 eeprom_read_blraw
.text.avr-libc
0x0000088a 0x1a C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
0x0000088a eeprom_write_byte
0x0000088c eeprom_write_r18
0x000008a4 . = ALIGN (0x2)
*(.fini9)
.fini9 0x000008a4 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
0x000008a4 _exit
0x000008a4 exit
*(.fini9)
*(.fini8)
*(.fini8)
*(.fini7)
*(.fini7)
*(.fini6)
*(.fini6)
*(.fini5)
*(.fini5)
*(.fini4)
*(.fini4)
*(.fini3)
*(.fini3)
*(.fini2)
*(.fini2)
*(.fini1)
*(.fini1)
*(.fini0)
.fini0 0x000008a4 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr25\libgcc.a(_exit.o)
*(.fini0)
0x000008a8 _etext = .
.data 0x00800100 0x4 load address 0x000008a8
0x00800100 PROVIDE (__data_start, .)
*(.data)
*(.data*)
.data.rgbled_sensitivity
0x00800100 0x4 src/led.o
*(.gnu.linkonce.d*)
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.r*)
0x00800104 . = ALIGN (0x2)
0x00800104 _edata = .
0x00800104 PROVIDE (__data_end, .)
.bss 0x00800104 0x30
0x00800104 PROVIDE (__bss_start, .)
*(.bss)
*(.bss*)
.bss.adc_averages
0x00800104 0x1 src/adc.o
.bss.rgbled_read_sel
0x00800105 0x1 src/led.o
.bss.temp_offset
0x00800106 0x2 src/main.o
.bss.temperature
0x00800108 0x1 src/main.o
.bss.pirate_sleep_mode
0x00800109 0x1 src/main.o
.bss.tim0_centi
0x0080010a 0x1 src/main.o
.bss.tim0_milli
0x0080010b 0x1 src/main.o
*(COMMON)
COMMON 0x0080010c 0x15 src/adc.o
0x0080010c adc_reread
0x0080010d adc_result
0x0080011f adc_busy
0x00800120 adc_read_mode
COMMON 0x00800121 0x9 src/led.o
0x00800121 rgbled_pwm_rt
0x00800125 rgbled_pwm_lf
0x00800129 timer1_mode
COMMON 0x0080012a 0xa src/main.o
0x0080012a comm_timeout
0x0080012b rgbled_light_level
0x0080012f comm_data
0x00800133 comm_data_idx
0x00800134 PROVIDE (__bss_end, .)
0x000008a8 __data_load_start = LOADADDR (.data)
0x000008ac __data_load_end = (__data_load_start + SIZEOF (.data))
.noinit 0x00800134 0x0
[!provide] PROVIDE (__noinit_start, .)
*(.noinit*)
[!provide] PROVIDE (__noinit_end, .)
0x00800134 _end = .
[!provide] PROVIDE (__heap_start, .)
.eeprom 0x00810000 0x0
*(.eeprom*)
0x00810000 __eeprom_end = .
.fuse
*(.fuse)
*(.lfuse)
*(.hfuse)
*(.efuse)
.lock
*(.lock*)
.signature
*(.signature*)
.user_signatures
*(.user_signatures*)
.stab
*(.stab)
.stabstr
*(.stabstr)
.stab.excl
*(.stab.excl)
.stab.exclstr
*(.stab.exclstr)
.stab.index
*(.stab.index)
.stab.indexstr
*(.stab.indexstr)
.comment 0x00000000 0x30
*(.comment)
.comment 0x00000000 0x30 src/adc.o
0x31 (size before relaxing)
.comment 0x00000030 0x31 src/led.o
.comment 0x00000030 0x31 src/main.o
.note.gnu.avr.deviceinfo
0x00000000 0x3c
.note.gnu.avr.deviceinfo
0x00000000 0x3c C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.note.gnu.build-id
*(.note.gnu.build-id)
.debug
*(.debug)
.line
*(.line)
.debug_srcinfo
*(.debug_srcinfo)
.debug_sfnames
*(.debug_sfnames)
.debug_aranges 0x00000000 0xa0
*(.debug_aranges)
.debug_aranges
0x00000000 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.debug_aranges
0x00000020 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.debug_aranges
0x00000040 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.debug_aranges
0x00000060 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.debug_aranges
0x00000080 0x20 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.debug_pubnames
*(.debug_pubnames)
.debug_info 0x00000000 0x8ce
*(.debug_info .gnu.linkonce.wi.*)
.debug_info 0x00000000 0x576 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.debug_info 0x00000576 0xab C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.debug_info 0x00000621 0xab C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.debug_info 0x000006cc 0xab C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.debug_info 0x00000777 0xac C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.debug_info 0x00000823 0xab C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.debug_abbrev 0x00000000 0x58f
*(.debug_abbrev)
.debug_abbrev 0x00000000 0x52b C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.debug_abbrev 0x0000052b 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.debug_abbrev 0x0000053f 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.debug_abbrev 0x00000553 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.debug_abbrev 0x00000567 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.debug_abbrev 0x0000057b 0x14 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.debug_line 0x00000000 0x376
*(.debug_line .debug_line.* .debug_line_end)
.debug_line 0x00000000 0x10f C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.debug_line 0x0000010f 0x74 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_byte.o)
.debug_line 0x00000183 0x61 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_word.o)
.debug_line 0x000001e4 0x5b C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_word.o)
.debug_line 0x0000023f 0x9f C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eerd_block.o)
.debug_line 0x000002de 0x98 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25\libattiny88.a(eewr_byte.o)
.debug_frame
*(.debug_frame)
.debug_str 0x00000000 0x1d9
*(.debug_str)
.debug_str 0x00000000 0x1d9 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/gcc/dev/attiny88/avr25/crtattiny88.o
.debug_loc
*(.debug_loc)
.debug_macinfo
*(.debug_macinfo)
.debug_weaknames
*(.debug_weaknames)
.debug_funcnames
*(.debug_funcnames)
.debug_typenames
*(.debug_typenames)
.debug_varnames
*(.debug_varnames)
.debug_pubtypes
*(.debug_pubtypes)
.debug_ranges
*(.debug_ranges)
.debug_macro
*(.debug_macro)
OUTPUT(wp_dc22_attiny88.elf elf32-avr)
LOAD linker stubs

View File

@ -0,0 +1,142 @@
S018000077705F646332325F617474696E7938382E7372656333
S11300002DC047C046C045C044C043C042C041C0E3
S113001040C03FC03EC03DC0AAC33BC03AC039C087
S11300208BC037C036C034C3BDC1C0C1CAC1DBC177
S1130030F8C116C228C227C2F9C103C224C223C20E
S113004022C221C220C209C20BC20AC21CC21BC2E4
S11300501AC219C218C217C216C207C211241FBE7F
S1130060CFEFD2E0DEBFCDBF11E0A0E0B1E0E8EA1F
S1130070F8E002C005900D92A430B107D9F721E051
S1130080A4E0B1E001C01D92A433B207E1F76DD240
S113009009C4B6CFE4E6F0E080818E7F8083EAE78E
S11300A0F0E08FED8083ACE7B0E08C918F7D8C9392
S11300B08081886880830895282F803188F4909106
S11300C07C00907F982B90937C00883030F481E002
S11300D001C0880F2A95EAF701C080E080937E0072
S11300E0613021F480917C00806405C0623029F481
S11300F080917C008F7B80937C00089590917A009E
S1130100292F207496FD15C080930C01662311F0ED
S1130110982F01C090E09093040190917C009F700F
S1130120906890931F0190917A00906490937A0064
S113013001C021E0822F08951F920F920FB60F92F3
S113014011242F934F935F938F939F93AF93BF93F8
S1130150EF93FF93E0917C00EF7020910401222340
S1130160D1F080910C012817B1F0E930A0F4AE2F42
S1130170B0E0AA0FBB1FA35FBE4F4D915C911197D6
S11301808091780090917900840F951F96958795BA
S113019011969C938E9380910C01882359F0809141
S11301A00C01815080930C0180917A0080648093CB
S11301B07A0011C021110DC0E93058F4F0E08091AB
S11301C0780090917900EE0FFF1FE35FFE4F91835B
S11301D0808310921F01FF91EF91BF91AF919F9186
S11301E08F915F914F912F910F900FBE0F901F90A1
S11301F018958AB1806F8AB987B18F6087B98BB13E
S1130200806F8BB988B18F6088B90895CF93DF93DD
S11302108BB1806F8BB988B18F6088B9C8E8D0E0A2
S11302208EEF8883AAE8B0E08C938AEF90E09093F5
S11302308500809384003BB124E02D0D81E090E0A3
S1130240AC0101C0440F2A95EAF7242F20952323FB
S11302502BB928B10D2C01C0880F0A94EAF78095B8
S1130260822388B9ED2DF0E0EB5DFE4F8BEF90819A
S1130270282F291B2883ED2DF0E0EF5DFE4F9081A0
S1130280891B8C93DF91CF9108959BB1906F9BB99B
S1130290E0E8F0E090819F70908397B1907F97B9E8
S11302A095B7906195BF47B121E030E0B90102C034
S11302B0660F771F8A95E2F7CB01462B47B998B1B1
S11302C0907F98B92A9A98B1982B98B92A9878E08F
S11302D07A95F1F797B18095982397B998B18923C6
S11302E088B985B78F7E85BF0895843038F4662336
S11302F029F0E82FF0E0E050FF4F60830895837009
S113030080930501089580910501E82FF0E0E05005
S1130310FF4F9081911101C091E02E2DE11003C097
S113032061E08FE012C0213019F460E080E018C071
S1130330223061F490911F01992319F0EE24E39483
S11303400895A3DF6FEF80910501B6CE4E2D50E0E6
S1130350892F90E002964817590719F461E083E069
S1130360CDCE8417950794F42150E22E80911F017D
S113037081110CC06FEF8FE09FDE3BDF8EEF809327
S1130380800084B1866084B91092200108958F2D75
S11303904F2D50E04A31510508F075C0FA01EC5E6A
S11303A0FF4F0994F12C10922A0108958091330192
S11303B0882309F46CC0F090300183E0809333010A
S11303C050C0E0912F01E43020F4F0E0EB5DFE4FEB
S11303D006C0E83008F044C0F0E0E35EFE4F8091D0
S11303E0300180833DC080913301882309F44FC0DC
S11303F080911D0190911E01892B09F444C06091E4
S11304001D0170911E0180913001681B710987FDE7
S1130410739570930701609306018EE390E024D2F4
S11304201FC0809133018230D8F41DC08091200117
S1130430811117C010922001E12C88E080932001E3
S113044010C08091200181110CC010922001E12C78
S113045080912F0154DF81E0F1CF84E08093090182
S1130460F12C10922A0180E00895809133018823B1
S113047071F080912F01843098F7609130016623E8
S113048079F333DFEDCFF12C10922A0181E0089546
S11304908093BB00ECEBF0E08081806880838081F6
S11304A08F7B808380E008958F2D8830B9F0893068
S11304B0C1F0843051F580912F01803428F490E00C
S11304C0C8D1E6DF81E006C08091BC008F7B8093B9
S11304D0BC008FEFF12C10922A010895809108013D
S11304E00EC0E0912F01E370F0E0EE0FFF1FE35F19
S11304F0FE4F808191819695879596958795C8DF63
S1130500F12C10922A0181E008958091BC008F7B28
S11305108093BC008FEF089580911D0190911E017E
S113052090910601891B982F959595959595891B12
S113053008958E2DE11003C062E088E0BDCD8330C4
S113054019F461E084E0DACD843070F08150E82E53
S113055080911F01811108C061E08FE0ADDD109230
S11305602001DADF80930801089580E88093610018
S11305701092610082B3806F82BB1DB881E084B9A0
S113058017B81AB8CFEFCEB9DEEFD5B9C8B9CBB921
S113059030DE22E02093B8008CEF8093B90086EE21
S11305A08093BA001092BD0085E48093BC008091D2
S11305B064008A7F809364009BEF95BD8DE387BDC3
S11305C016BC20936E00809164008C7F809364003D
S11305D0C0938900C0938800C0938A00109285005C
S11305E010928400D093800089E18093810010925E
S11305F0820080918000809329019093860084B1C9
S1130600866084B910926F0045DD629923C042DD93
S11306102FEF80E792E0215080409040E1F700C046
S11306200000629917C0789488E08093200181DFEC
S113063080911F018111FCCF60911D0170911E01F9
S113064070930701609306018EE390E00DD1109240
S113065020010DC08EE390E003D1813322E09207A4
S113066014F081E191E0909307018093060183B730
S1130670897F90910901892B83BF10920901789495
S113068083B7816083BF889583B78E7F83BFEFCFA5
S11306901F920F920FB60F9211242F933F934F93F3
S11306A05F936F937F938F939F93AF93BF93EF93D6
S11306B0FF938091B900887F803AF1F160F4883625
S11306C009F43FC028F4882391F18036D1F134C075
S11306D0803839F031C0883B41F170F5883A29F10E
S11306E02BC08091BB00F1100FC0982F92959F7082
S11306F0F92E982F9F7090932F011092330110922E
S11307002A0187FF1EC00AC0E0913301EF5FE37046
S1130710E0933301F0E0E15DFE4F808338DE88230F
S113072081F08091BC008F7B0AC0BEDE0AC080913C
S1130730BC0080698093BC008091BC00806480937D
S1130740BC008091BC0080688093BC00FF91EF9155
S1130750BF91AF919F918F917F916F915F914F91D5
S11307603F912F910F900FBE0F901F9018951F92DD
S11307700F920FB60F9211242F933F934F935F93D1
S11307806F937F938F939F93AF93BF93EF93FF9355
S113079080910B018F5F883C18F480930B010CC08F
S11307A010920B0180910A018F5F843618F48093B4
S11307B00A0102C010920A0187B58D3311F08DE34E
S11307C001C08EE387BD80912001882371F0809160
S11307D02001813021F0883019F4ABDE01C093DDB3
S11307E08E2D8F3F11F08F5FE82E80912001813094
S11307F041F081E08D0D833010F4D82E01C0D12C4E
S113080005DDFF20A1F080912A018F5F80932A01EA
S1130810823368F0F12C10922A018091BC008F7B06
S11308208093BC008091BC0080648093BC0086B53A
S1130830FF91EF91BF91AF919F918F917F916F91B4
S11308405F914F913F912F910F900FBE0F901F908A
S11308501895F999FECF81BDF89A992780B5089526
S1130860A8E1B0E042E005C010D0272F0FC0DC01A2
S1130870862FE82FF999FECF05C0E1BDF89AE395DC
S113088000B40D924150C8F70895262FF999FECF70
S11308901FBA81BD20BD0FB6F894FA9AF99A0FBE1B
S10B08A001960895F894FFCFBE
S10708A80101010144
S9030000FC

Binary file not shown.

View File

@ -0,0 +1,141 @@
:100000002DC047C046C045C044C043C042C041C0E7
:1000100040C03FC03EC03DC0AAC33BC03AC039C08B
:100020008BC037C036C034C3BDC1C0C1CAC1DBC17B
:10003000F8C116C228C227C2F9C103C224C223C212
:1000400022C221C220C209C20BC20AC21CC21BC2E8
:100050001AC219C218C217C216C207C211241FBE83
:10006000CFEFD2E0DEBFCDBF11E0A0E0B1E0E8EA23
:10007000F8E002C005900D92A430B107D9F721E055
:10008000A4E0B1E001C01D92A433B207E1F76DD244
:1000900009C4B6CFE4E6F0E080818E7F8083EAE792
:1000A000F0E08FED8083ACE7B0E08C918F7D8C9396
:1000B0008081886880830895282F803188F490910A
:1000C0007C00907F982B90937C00883030F481E006
:1000D00001C0880F2A95EAF701C080E080937E0076
:1000E000613021F480917C00806405C0623029F485
:1000F00080917C008F7B80937C00089590917A00A2
:10010000292F207496FD15C080930C01662311F0F1
:10011000982F01C090E09093040190917C009F7013
:10012000906890931F0190917A00906490937A0068
:1001300001C021E0822F08951F920F920FB60F92F7
:1001400011242F934F935F938F939F93AF93BF93FC
:10015000EF93FF93E0917C00EF7020910401222344
:10016000D1F080910C012817B1F0E930A0F4AE2F46
:10017000B0E0AA0FBB1FA35FBE4F4D915C911197DA
:100180008091780090917900840F951F96958795BE
:1001900011969C938E9380910C01882359F0809145
:1001A0000C01815080930C0180917A0080648093CF
:1001B0007A0011C021110DC0E93058F4F0E08091AF
:1001C000780090917900EE0FFF1FE35FFE4F91835F
:1001D000808310921F01FF91EF91BF91AF919F918A
:1001E0008F915F914F912F910F900FBE0F901F90A5
:1001F00018958AB1806F8AB987B18F6087B98BB142
:10020000806F8BB988B18F6088B90895CF93DF93E1
:100210008BB1806F8BB988B18F6088B9C8E8D0E0A6
:100220008EEF8883AAE8B0E08C938AEF90E09093F9
:100230008500809384003BB124E02D0D81E090E0A7
:10024000AC0101C0440F2A95EAF7242F20952323FF
:100250002BB928B10D2C01C0880F0A94EAF78095BC
:10026000822388B9ED2DF0E0EB5DFE4F8BEF90819E
:10027000282F291B2883ED2DF0E0EF5DFE4F9081A4
:10028000891B8C93DF91CF9108959BB1906F9BB99F
:10029000E0E8F0E090819F70908397B1907F97B9EC
:1002A00095B7906195BF47B121E030E0B90102C038
:1002B000660F771F8A95E2F7CB01462B47B998B1B5
:1002C000907F98B92A9A98B1982B98B92A9878E093
:1002D0007A95F1F797B18095982397B998B18923CA
:1002E00088B985B78F7E85BF0895843038F466233A
:1002F00029F0E82FF0E0E050FF4F6083089583700D
:1003000080930501089580910501E82FF0E0E05009
:10031000FF4F9081911101C091E02E2DE11003C09B
:1003200061E08FE012C0213019F460E080E018C075
:10033000223061F490911F01992319F0EE24E39487
:100340000895A3DF6FEF80910501B6CE4E2D50E0EA
:10035000892F90E002964817590719F461E083E06D
:10036000CDCE8417950794F42150E22E80911F0181
:1003700081110CC06FEF8FE09FDE3BDF8EEF80932B
:10038000800084B1866084B91092200108958F2D79
:100390004F2D50E04A31510508F075C0FA01EC5E6E
:1003A000FF4F0994F12C10922A0108958091330196
:1003B000882309F46CC0F090300183E0809333010E
:1003C00050C0E0912F01E43020F4F0E0EB5DFE4FEF
:1003D00006C0E83008F044C0F0E0E35EFE4F8091D4
:1003E000300180833DC080913301882309F44FC0E0
:1003F00080911D0190911E01892B09F444C06091E8
:100400001D0170911E0180913001681B710987FDEB
:10041000739570930701609306018EE390E024D2F8
:100420001FC0809133018230D8F41DC0809120011B
:10043000811117C010922001E12C88E080932001E7
:1004400010C08091200181110CC010922001E12C7C
:1004500080912F0154DF81E0F1CF84E08093090186
:10046000F12C10922A0180E00895809133018823B5
:1004700071F080912F01843098F7609130016623EC
:1004800079F333DFEDCFF12C10922A0181E008954A
:100490008093BB00ECEBF0E08081806880838081FA
:1004A0008F7B808380E008958F2D8830B9F089306C
:1004B000C1F0843051F580912F01803428F490E010
:1004C000C8D1E6DF81E006C08091BC008F7B8093BD
:1004D000BC008FEFF12C10922A0108958091080141
:1004E0000EC0E0912F01E370F0E0EE0FFF1FE35F1D
:1004F000FE4F808191819695879596958795C8DF67
:10050000F12C10922A0181E008958091BC008F7B2C
:100510008093BC008FEF089580911D0190911E0182
:1005200090910601891B982F959595959595891B16
:1005300008958E2DE11003C062E088E0BDCD8330C8
:1005400019F461E084E0DACD843070F08150E82E57
:1005500080911F01811108C061E08FE0ADDD109234
:100560002001DADF80930801089580E8809361001C
:100570001092610082B3806F82BB1DB881E084B9A4
:1005800017B81AB8CFEFCEB9DEEFD5B9C8B9CBB925
:1005900030DE22E02093B8008CEF8093B90086EE25
:1005A0008093BA001092BD0085E48093BC008091D6
:1005B00064008A7F809364009BEF95BD8DE387BDC7
:1005C00016BC20936E00809164008C7F8093640041
:1005D000C0938900C0938800C0938A001092850060
:1005E00010928400D093800089E180938100109262
:1005F000820080918000809329019093860084B1CD
:10060000866084B910926F0045DD629923C042DD97
:100610002FEF80E792E0215080409040E1F700C04A
:100620000000629917C0789488E08093200181DFF0
:1006300080911F018111FCCF60911D0170911E01FD
:1006400070930701609306018EE390E00DD1109244
:1006500020010DC08EE390E003D1813322E09207A8
:1006600014F081E191E0909307018093060183B734
:10067000897F90910901892B83BF10920901789499
:1006800083B7816083BF889583B78E7F83BFEFCFA9
:100690001F920F920FB60F9211242F933F934F93F7
:1006A0005F936F937F938F939F93AF93BF93EF93DA
:1006B000FF938091B900887F803AF1F160F4883629
:1006C00009F43FC028F4882391F18036D1F134C079
:1006D000803839F031C0883B41F170F5883A29F112
:1006E0002BC08091BB00F1100FC0982F92959F7086
:1006F000F92E982F9F7090932F0110923301109232
:100700002A0187FF1EC00AC0E0913301EF5FE3704A
:10071000E0933301F0E0E15DFE4F808338DE882313
:1007200081F08091BC008F7B0AC0BEDE0AC0809140
:10073000BC0080698093BC008091BC008064809381
:10074000BC008091BC0080688093BC00FF91EF9159
:10075000BF91AF919F918F917F916F915F914F91D9
:100760003F912F910F900FBE0F901F9018951F92E1
:100770000F920FB60F9211242F933F934F935F93D5
:100780006F937F938F939F93AF93BF93EF93FF9359
:1007900080910B018F5F883C18F480930B010CC093
:1007A00010920B0180910A018F5F843618F48093B8
:1007B0000A0102C010920A0187B58D3311F08DE352
:1007C00001C08EE387BD80912001882371F0809164
:1007D0002001813021F0883019F4ABDE01C093DDB7
:1007E0008E2D8F3F11F08F5FE82E80912001813098
:1007F00041F081E08D0D833010F4D82E01C0D12C52
:1008000005DDFF20A1F080912A018F5F80932A01EE
:10081000823368F0F12C10922A018091BC008F7B0A
:100820008093BC008091BC0080648093BC0086B53E
:10083000FF91EF91BF91AF919F918F917F916F91B8
:100840005F914F913F912F910F900FBE0F901F908E
:100850001895F999FECF81BDF89A992780B508952A
:10086000A8E1B0E042E005C010D0272F0FC0DC01A6
:10087000862FE82FF999FECF05C0E1BDF89AE395E0
:1008800000B40D924150C8F70895262FF999FECF74
:100890001FBA81BD20BD0FB6F894FA9AF99A0FBE1F
:0808A00001960895F894FFCFC2
:0408A8000101010148
:00000001FF

5
fw_dc22_stm32l100/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch

View File

@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

View File

@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

View File

@ -0,0 +1,98 @@
/**
* pirate.h: half-assed piracy-enabling features for drunken, brazen pirates
* 2014 by true
*
* ----
*
* $Id: pirate.h 505 2021-09-05 19:07:51Z true $
*
**/
#ifndef __PIRATE_PIRATE_H
#define __PIRATE_PIRATE_H
#include <stdlib.h>
#include <stdint.h>
/* cmsis req'd */
#include "stm32l1xx_conf.h"
#define PIRATE_PROG_SAVED_MAX 15
/* helper macros */
#define sizeof_array(x) sizeof(x) / sizeof(x[0])
/* pirate settings */
#define PIRATE_PROG_MATRIX 0
#define PIRATE_PROG_BONES 1
#define PIRATE_PROG_EYES 2
typedef struct PirateProg {
uint8_t type; // bit0 = pattern(high)/program(low), bit1 = always init, bit7 = enabled
uint8_t progidx;
uint16_t wait;
uint16_t level;
uint32_t offset;
uint32_t option;
uint16_t dwell;
} PirateProg;
typedef struct PirateSettings {
char name[32];
uint8_t fav_color[3];
uint8_t beeper;
uint8_t beep_type[8];
uint8_t contrast;
uint8_t autorun;
uint8_t led_autoadjust;
uint8_t led_autogain_lev_min;
uint8_t led_autogain_lev_max;
uint8_t led_autothresh[5];
uint8_t light_setgain;
uint8_t lcd_autobrite;
uint8_t lcd_brightness;
PirateProg led_prog[3][PIRATE_PROG_SAVED_MAX];
uint8_t led_prog_mode;
uint16_t mic_cal[2];
} PirateSettings;
extern PirateSettings settings;
#define PIRATE_SETTINGS_EEPROM_ADDR (uint32_t)0x8080000
/* misc extras */
extern uint8_t temperature;
extern int8_t temperature_cal;
extern uint8_t light_level;
extern uint8_t light_gain;
extern uint16_t mic_peak;
extern uint8_t dc23_nametx;
/* pirate variables */
extern uint32_t pirate_prng_val;
/* pirate functions */
void pirate_shutdown(uint16_t type);
uint8_t pirate_prng();
void pirate_delay(uint16_t ms);
int16_t pirate_scale(int16_t value, int16_t src_min, int16_t src_max, int16_t dest_min, int16_t dest_max);
char * pirate_itoa(uint32_t val, uint8_t base, uint8_t leftpad);
char * pirate_sitoa(int32_t val, uint8_t base, uint8_t leftpad);
uint16_t pirate_batt_voltage();
void pirate_batt_log(uint16_t rawvalue);
uint16_t pirate_thermometer(uint8_t deg_f);
void pirate_thermometer_log(uint8_t temp);
#endif

View File

@ -0,0 +1,85 @@
/**
******************************************************************************
* @file USART/USART_TwoBoards/DataExchangeDMA/stm32l1xx_conf.h
* @author MCD Application Team
* @version V1.2.0
* @date 16-May-2014
* @brief Library configuration file.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L1xx_CONF_H
#define __STM32L1xx_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */
#include "stm32l1xx_adc.h"
//#include "stm32l1xx_aes.h"
//#include "stm32l1xx_comp.h"
#include "stm32l1xx_crc.h"
#include "stm32l1xx_dac.h"
//#include "stm32l1xx_dbgmcu.h"
#include "stm32l1xx_dma.h"
#include "stm32l1xx_exti.h"
#include "stm32l1xx_flash.h"
//#include "stm32l1xx_fsmc.h"
#include "stm32l1xx_gpio.h"
#include "stm32l1xx_i2c.h"
//#include "stm32l1xx_iwdg.h"
//#include "stm32l1xx_lcd.h"
//#include "stm32l1xx_opamp.h"
#include "stm32l1xx_pwr.h"
#include "stm32l1xx_rcc.h"
//#include "stm32l1xx_rtc.h"
//#include "stm32l1xx_sdio.h"
#include "stm32l1xx_spi.h"
#include "stm32l1xx_syscfg.h"
#include "stm32l1xx_tim.h"
#include "stm32l1xx_usart.h"
//#include "stm32l1xx_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Uncomment the line below to expanse the "assert_param" macro in the
Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT 1 */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function which reports
* the name of the source file and the source line number of the call
* that failed. If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
#endif /* __STM32L1xx_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,52 @@
/**
******************************************************************************
* @file ADC/ADC1_AnalogWatchdog/stm32l1xx_it.h
* @author MCD Application Team
* @version V1.2.2
* @date 17-November-2021
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* Copyright (c) 2015 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L1xx_IT_H
#define __STM32L1xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
#ifdef __cplusplus
}
#endif
#endif /* __STM32L1xx_IT_H */

View File

@ -0,0 +1,103 @@
/**
******************************************************************************
* @file usb_conf.h
* @author MCD Application Team
* @version V4.0.0
* @date 21-January-2013
* @brief Virtual COM Port Demo configuration header
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_CONF_H
#define __USB_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* External variables --------------------------------------------------------*/
/*-------------------------------------------------------------*/
/* EP_NUM */
/* defines how many endpoints are used by the device */
/*-------------------------------------------------------------*/
#define EP_NUM (4)
/*-------------------------------------------------------------*/
/* -------------- Buffer Description Table -----------------*/
/*-------------------------------------------------------------*/
/* buffer table base address */
/* buffer table base address */
#define BTABLE_ADDRESS (0x00)
/* EP0 */
/* rx/tx buffer base address */
#define ENDP0_RXADDR (0x40)
#define ENDP0_TXADDR (0x80)
/* EP1 */
/* tx buffer base address */
#define ENDP1_TXADDR (0xC0)
#define ENDP2_TXADDR (0x100)
#define ENDP3_RXADDR (0x110)
/*-------------------------------------------------------------*/
/* ------------------- ISTR events -------------------------*/
/*-------------------------------------------------------------*/
/* IMR_MSK */
/* mask defining which events has to be handled */
/* by the device application software */
// #define IMR_MSK (CNTR_CTRM | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM | CNTR_SOFM | CNTR_ESOFM | CNTR_RESETM )
#define IMR_MSK (CNTR_CTRM | CNTR_WKUPM | CNTR_ERRM | CNTR_SOFM | CNTR_RESETM)
/*#define CTR_CALLBACK*/
/*#define DOVR_CALLBACK*/
/*#define ERR_CALLBACK*/
/*#define WKUP_CALLBACK*/
/*#define SUSP_CALLBACK*/
/*#define RESET_CALLBACK*/
#define SOF_CALLBACK
/*#define ESOF_CALLBACK*/
/* CTR service routines */
/* associated to defined endpoints */
/*#define EP1_IN_Callback NOP_Process*/
#define EP2_IN_Callback NOP_Process
#define EP3_IN_Callback NOP_Process
#define EP4_IN_Callback NOP_Process
#define EP5_IN_Callback NOP_Process
#define EP6_IN_Callback NOP_Process
#define EP7_IN_Callback NOP_Process
#define EP1_OUT_Callback NOP_Process
#define EP2_OUT_Callback NOP_Process
/*#define EP3_OUT_Callback NOP_Process*/
#define EP4_OUT_Callback NOP_Process
#define EP5_OUT_Callback NOP_Process
#define EP6_OUT_Callback NOP_Process
#define EP7_OUT_Callback NOP_Process
#endif /* __USB_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

View File

@ -0,0 +1,51 @@
/* improved reference xxtea implementation */
#include <stdint.h>
#define DELTA 0x9e3779b9
#define MX ( (((z>>5)^(y<<2))+((y>>3)^(z<<4)))^((sum^y)+(key[(p&3)^e]^z)) );
/* btea usage:
* uint32_t *v is the pointer to the data
* int n is word count of v to en/decode. positive to encode, negative to decode
* const key[4] is the 128-bit key
*/
void btea(uint32_t *v, int n, uint32_t const key[4]) {
uint32_t y, z, sum;
int32_t p, rounds, e;
if (n > 1) { /* Coding Part */
rounds = 6 + 52/n;
sum = 0;
z = v[n-1];
do {
sum += DELTA;
e = (sum >> 2) & 3;
for (p = 0; p < n - 1; p++) {
y = v[p + 1];
z = v[p] += MX;
}
y = v[0];
z = v[n - 1] += MX;
} while (--rounds);
} else if (n < -1) { /* Decoding Part */
n = -n;
rounds = 6 + 52/n;
sum = rounds * DELTA;
y = v[0];
do {
e = (sum >> 2) & 3;
for (p = n - 1; p > 0; p--) {
z = v[p - 1];
y = v[p] -= MX;
}
z = v[n - 1];
y = v[0] -= MX;
sum -= DELTA;
} while (--rounds);
}
}

View File

@ -0,0 +1,4 @@
/* improved reference xxtea implementation */
void btea(uint32_t *v, int n, uint32_t const key[4]);

View File

@ -0,0 +1,19 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:wp_dc22_stm32l]
platform = ststm32
board = disco_l152rb
framework = spl
board_build.mcu = stm32l100rbt6
board_build.f_cpu = 32000000L
build_flags = -DPDLIB_SPI

View File

@ -0,0 +1,182 @@
/**
* attiny.c: interface to attiny88's features
* 2014 true
*
* ----
*
* $Id: attiny.c 375 2015-07-06 02:52:40Z true $
*
* ----
*
* attiny88's I2C address is 0x73 - see led_eyes.h for define
*
**/
#include <pirate.h> // for settings
#include "attiny.h"
#include "../interface/i2c.h"
#include "../interface/gpio.h"
#include "../device/lightsensor.h"
// led mode
static uint8_t led_eyes_mode;
// led brightness
static uint8_t led_level[2][4];
// led programs
#include "../led/led_eyes_prog.h"
static void (*led_program)();
static void (*led_program_list[])() = {
led_prog_candle_flicker,
led_prog_candle_flicker_favcolor,
led_prog_randflasher,
led_prog_mic_spl,
led_prog_fader
};
const char led_eyes_prog_name[LED_EYES_PROG_COUNT][16] = {
{"CandleFlicker"},
{"Candle+FavColor"},
{"RandFlasher"},
{"MicSPL"},
{"CFader"}
};
/* functions */
void attiny_write(uint16_t cmd, void *data, uint8_t bytes)
{
uint8_t cmdlen;
uint8_t *d;
cmdlen = (cmd > 0xff) ? 2 : 1;
d = ((uint8_t *)data);
if (bytes) {
I2C_WriteTransfer(ATTINY_I2C_ADDR, d, bytes, cmd, cmdlen);
}
}
uint32_t attiny_read(uint16_t cmd, uint8_t bytes)
{
uint8_t cmdlen;
uint8_t fb[4] = {0, 0, 0, 0};
cmdlen = (cmd > 0xff) ? 2 : 1;
if (bytes && bytes <= 4) {
I2C_ReadTransfer(ATTINY_I2C_ADDR, fb, bytes, cmd, cmdlen);
}
return fb[0] | fb[1] << 8 | fb[2] << 16 | fb[3] << 24;
}
uint8_t attiny_read_temp()
{
return (uint8_t)attiny_read(ATTINY_CMD_READ_TEMP, 1);
}
uint8_t attiny_read_light_level(uint8_t led_idx)
{
return (uint8_t)attiny_read(ATTINY_CMD_READ_LIGHT + (led_idx & 0x03), 1);
}
void attiny_write_light_sensitivity(uint8_t led, uint8_t sensitivity)
{
uint8_t buf[2];
buf[0] = led;
buf[1] = sensitivity;
attiny_write(ATTINY_CMD_LIGHTSENSOR_SENS, buf, 2);
}
void attiny_sleep()
{
I2C_WriteTransfer(ATTINY_I2C_ADDR, 0, 0, ATTINY_CMD_SLEEP, 1);
}
/* rgbled-related functions */
void led_eyes_tx()
{
uint8_t buf[12];
uint16_t scaler;
uint8_t i, j;
// build up the packet
i = j = 0;
while (i < 12) {
buf[i++] = ATTINY_CMD_LED_LEVEL + j;
scaler = (settings.led_autoadjust & 0x80) ? lightsensor_get_scalerval(LIGHTSENS_SCALED_EYES) : 256;
buf[i++] = ((led_level[j >> 2][j % 4]) * scaler) >> 8;
if (i == 6) {
j = 4;
} else {
j++;
}
}
// and send it
I2C_WriteTransfer(ATTINY_I2C_ADDR, buf, 12, 0, 0);
}
void led_eyes_set_level(uint8_t idx, uint8_t level)
{
led_level[idx >> 2][idx & 0x03] = level;
}
void led_eyes_set_mode(uint8_t mode)
{
led_eyes_mode = mode;
}
void led_eyes_set_program(uint8_t program_idx, uint8_t init,
uint16_t wait, uint16_t level, uint32_t offset, uint32_t settings)
{
// we need to be in program mode
led_eyes_set_mode(LED_EYES_MODE_PROGRAM);
// update the program pointer
led_program = led_program_list[program_idx];
// set initial program variables
led_prog_set_wait = wait;
led_prog_set_level = level;
led_prog_set_offset = offset;
led_prog_set_option = settings;
// is this a new set? if so, initialize program parameters
if (init) {
uint8_t i;
led_prog_wait = 0;
for (i = 0; i < 4; i++) {
led_prog_state[i] = 0;
led_prog_work[i] = 0;
}
}
}
void led_eyes_mode_update()
{
uint8_t i;
switch (led_eyes_mode) {
case LED_EYES_MODE_PROGRAM: {
// if we have a valid program loaded, run it
if (led_program != NULL) {
led_program();
}
break;
}
case LED_EYES_MODE_OFF: {
led_program = NULL;
for (i = 0; i < 4; i++) {
led_level[0][i] = 0;
led_level[1][i] = 0;
}
break;
}
}
}

View File

@ -0,0 +1,65 @@
/**
* attiny.h: interface to attiny88's RGBLED eyes prototypes
* 2014 true
*
* ----
*
* $Id: attiny.h 375 2015-07-06 02:52:40Z true $
*
**/
#ifndef __PIRATE_DEV_ATTINY_H
#define __PIRATE_DEV_ATTINY_H
/* interface */
#define ATTINY_I2C_DEV I2C1
#define ATTINY_I2C_ADDR 0x73
// write register commands, last 4 bits = data, >1 packet
#define ATTINY_CMD_EXT_CMD 0x10 // pkt = ext command (bit[7:4] must NOT == 0)
#define ATTINY_CMD_LED_LEVEL 0x20 // cmd[3:0] = led, pkt = level (0-250)
#define ATTINY_CMD_TEMP_CAL 0x30 // pkt = current temperature
#define ATTINY_CMD_EEPROM_READ 0x40 // pkt = address, read 1 byte after this command
#define ATTINY_CMD_EEPROM_WRITE 0x50 // pkt[0] = address, pkt[1] = data
// write register commands, last 4 bits = data, immediate processing 1 packet
#define ATTINY_CMD_READ_TEMP 0x80 // read 1 byte after this command
#define ATTINY_CMD_READ_LIGHT 0x90 // cmd[3:0] = led (from 0-3), read 1 byte after this command
#define ATTINY_CMD_SLEEP 0xF0 // no data
// write register commands, extended
#define ATTINY_CMD_LIGHTSENSOR_SENS 0x1019 // 2 bytes data - led, new sensitivity value
/* leds */
#define LED_EYES_LEFT 0
#define LED_EYES_RIGHT 1
/* programs */
#define LED_EYES_MODE_OFF 0
#define LED_EYES_MODE_PROGRAM 2
#define LED_EYES_PROG_COUNT 5
#define LED_EYES_PTRN_COUNT 0
/* prototypes */
void led_eyes_tx();
void led_eyes_set_level(uint8_t idx, uint8_t level);
void led_eyes_mode_update();
void led_eyes_set_mode(uint8_t mode); // used for disabling
void led_eyes_set_program(uint8_t program_idx, uint8_t init,
uint16_t wait, uint16_t level, uint32_t offset, uint32_t settings);
uint8_t attiny_read_temp();
uint8_t attiny_read_light_level(uint8_t led_idx);
void attiny_write_light_sensitivity(uint8_t led, uint8_t sensitivity);
void attiny_sleep();
#endif

View File

@ -0,0 +1,118 @@
/**
* beep.c: beeper fuckin musicality bitches, beep buzz boop
* 2014 by true
*
* ----
*
* $Id: beep.c 327 2015-02-18 04:43:42Z true $
*
* ----
*
* TODO: remove freq lookup table, replace with freq defines by note (A4 = 440 for example)
* TODO: let you know that the device we chose cannot play music; it is a buzzer.
* TODO: do what you want 'cause a pirate is free
**/
#include <pirate.h>
#include "beep.h"
#include "../interface/gpio.h"
const tGPIO beep_pin = {GPIOA, GPIO_Pin_4, 4};
uint8_t beep_buf_idx;
uint8_t beep_play_idx;
uint16_t beep_dur_buf[BEEP_BUF_SIZE];
uint16_t beep_lev_buf[BEEP_BUF_SIZE];
/* beeper bullshit */
void beep_init()
{
GPIO_InitTypeDef gpio;
// set up beeper gpio struct
gpio.GPIO_Mode = GPIO_Mode_OUT;
gpio.GPIO_OType = GPIO_OType_PP;
gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
gpio.GPIO_Speed = GPIO_Speed_400KHz;
gpio.GPIO_Pin = beep_pin.pin;
// and set it up
GPIO_Init(beep_pin.port, &gpio);
// reset buffer index
beep_buf_idx = 0;
}
void beep_update()
{
uint16_t duration;
uint16_t level;
// do we have an active tone?
if (beep_buf_idx & 0x80) {
duration = beep_dur_buf[beep_play_idx];
level = beep_lev_buf[beep_play_idx];
if (duration) {
if (level == 0) { // loudest
GPIO_SetBits(beep_pin.port, beep_pin.pin);
} else if (level == 32) { // silent
GPIO_ResetBits(beep_pin.port, beep_pin.pin);
} else if (duration % level == 0) { // tones
GPIO_SetBits(beep_pin.port, beep_pin.pin);
} else {
GPIO_ResetBits(beep_pin.port, beep_pin.pin);
}
// count down the times
beep_dur_buf[beep_play_idx]--;
} else {
// stop the tone
GPIO_ResetBits(beep_pin.port, beep_pin.pin);
// move to the next buffer
beep_play_idx++;
// is there any more? need to reset buffer if there isn't any more
if (((beep_buf_idx & 0x7f) == beep_play_idx) || beep_play_idx >= BEEP_BUF_SIZE) {
// nope, no more
beep_buf_idx = 0;
beep_play_idx = 0;
}
}
}
}
/* beep control */
void beep_clear_queue()
{
beep_buf_idx = 0;
GPIO_ResetBits(beep_pin.port, beep_pin.pin);
}
uint16_t beep(uint16_t tone_id, uint16_t duration)
{
if ((beep_buf_idx & 0x7f) < BEEP_BUF_SIZE) {
// if not in use, reset the playback index
if (beep_buf_idx == 0) {
beep_play_idx = 0;
}
// mark the beeper as being used
beep_buf_idx |= 0x80;
// set the desired tone and duration
beep_lev_buf[beep_buf_idx & 0x7f] = (tone_id < 32) ? 32 - tone_id : 0;
beep_dur_buf[beep_buf_idx & 0x7f] = duration * 5;
// prepare for the next buffer location
beep_buf_idx++;
return (beep_buf_idx & 0x7f);
}
return 0xff;
}

View File

@ -0,0 +1,32 @@
/**
* beep.h: beeper fuckin musicality bitches
* 2014 by true
*
* ----
*
* $Id: beep.h 327 2015-02-18 04:43:42Z true $
*
* do what you want 'cause a pirate is free
* you are a pirate
*
**/
#ifndef __PIRATE_DEV_BEEP_H
#define __PIRATE_DEV_BEEP_H
/* constants */
#define BEEP_BUF_SIZE 8 // max 127
/* prototypes */
void beep_init();
void beep_update();
void beep_clear_queue();
uint16_t beep(uint16_t tone_id, uint16_t duration);
#endif

View File

@ -0,0 +1,30 @@
/**
* beep_music.h: musical scores for pirates
* 2014 by true
*
* ----
*
* $Id: beep_song.h 327 2015-02-18 04:43:42Z true $
*
**/
static MusicSong you_are_a_pirate[] = {
{5, NOTE_E, 200},
{5, NOTE_C, 200},
{5, NOTE_C, 200},
{5, NOTE_C, 200},
{4, NOTE_G, 200},
{4, NOTE_A, 200},
{5, NOTE_C, 200},
{4, NOTE_B, 200},
{4, NOTE_D, 200},
{4, NOTE_A, 250},
{0, NOTE_NONE, 350},
{4, NOTE_G, 600},
{5, NOTE_C, 600},
{5, NOTE_C, 200},
{5, NOTE_D, 360},
{4, NOTE_A, 360}
};
static MusicPlaylist you_are_a_pirate_s = {you_are_a_pirate, 16};

View File

@ -0,0 +1,225 @@
/**
* lcd.c: lcd menuing and support functions
* 2014 by true
*
* ----
*
* $Id: lcd.c 327 2015-02-18 04:43:42Z true $
*
**/
#include <pirate.h>
#include "lcd.h"
#include "../interface/i2c.h"
#include "../interface/gpio.h"
// led backlight
uint16_t lcd_led_level = 0;
uint16_t lcd_led_level_set = 0;
uint8_t lcd_led_rate;
uint8_t lcd_led_upd;
// lcd control
uint8_t lcd_height;
uint8_t lcd_cursor_pos;
uint8_t lcd_cursor_type;
uint8_t (*lcd_cgram)[8];
uint8_t lcd_cgram_len;
// lcd display
char lcd_line[2][9];
// lcd hardware
const tGPIO lcd_led_pin = {GPIOA, GPIO_Pin_6, 6};
/* functions */
void lcd_init()
{
static const uint8_t cmd_init[] = {
0x38, // set to i2c
0x39, // set to i2c
0x1d, // 1/4 bias, osc ~220hz
0x78, // contrast low 4 bits
0x5d, // icon enable, voltage boost enable, contrast high 2 bits
0x6d, // internal follower enable,
0x0c, // display on
0x01, // clear display
0x06 //
};
uint8_t *cmdptr = (uint8_t *)cmd_init;
I2C_WriteTransfer(LCD_I2C_ADDR, cmdptr, 9, LCD_CMD, 1);
// set stored contrast
lcd_set_contrast(settings.contrast);
}
void lcd_led_init()
{
TIM_TimeBaseInitTypeDef tim_tb;
TIM_OCInitTypeDef tim_oc;
GPIO_InitTypeDef gpio;
// enable clocks
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM10, ENABLE);
// set up with 250 levels of brightness, with a bit of empty
tim_tb.TIM_Prescaler = 5 - 1; // 6.4MHz
tim_tb.TIM_Period = 320 - 1; // 25KHz PWM
tim_tb.TIM_ClockDivision = 0;
tim_tb.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(LCD_LED_TIMER, &tim_tb);
// configure outputs as pwm
tim_oc.TIM_OCMode = TIM_OCMode_PWM1;
tim_oc.TIM_OutputState = TIM_OutputState_Enable;
tim_oc.TIM_Pulse = 0;
tim_oc.TIM_OCPolarity = LCD_LED_OC_POLARITY;
TIM_OC1Init(LCD_LED_TIMER, &tim_oc);
TIM_OC1PreloadConfig(LCD_LED_TIMER, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(LCD_LED_TIMER, ENABLE);
TIM_Cmd(LCD_LED_TIMER, ENABLE);
// configure output pin as timer AF
GPIO_StructInit(&gpio);
gpio.GPIO_Mode = GPIO_Mode_AF;
gpio.GPIO_Speed = GPIO_Speed_2MHz;
gpio.GPIO_Pin = lcd_led_pin.pin;
GPIO_Init(lcd_led_pin.port, &gpio);
GPIO_PinAFConfig(lcd_led_pin.port, lcd_led_pin.pinsource, GPIO_AF_TIM10);
}
void lcd_print(uint8_t pos, uint8_t *msg, uint8_t msg_len)
{
uint8_t len;
// which line/pos to print to?
I2C_WriteTransfer(LCD_I2C_ADDR, &pos, 1, LCD_CMD, 1);
// length to print
len = msg_len < LCD_MAX_LINE_LENGTH ? msg_len : LCD_MAX_LINE_LENGTH;
// send it
I2C_WriteTransfer(LCD_I2C_ADDR, msg, len, LCD_DATA, 1);
}
void lcd_linebuf_send()
{
lcd_print(LCD_LINE_1, (uint8_t *)lcd_line[0], 8);
if (lcd_get_height() != LCD_CMD_DOUBLEHEIGHT) {
lcd_print(LCD_LINE_2, (uint8_t *)lcd_line[1], 8);
}
}
void lcd_cmd(uint8_t cmd)
{
I2C_WriteTransfer(LCD_I2C_ADDR, &cmd, 1, LCD_CMD, 1);
// pirate_delay(1);
}
void lcd_set_contrast(uint8_t level) {
settings.contrast = level & 0x3f;
}
void lcd_apply_contrast()
{
// contrast is 6 bits; can be between 0 and 63
uint8_t cmd[2] = {0};
// form command
cmd[0] = 0x5c | (settings.contrast >> 4);
cmd[1] = 0x70 | (settings.contrast & 0x0f);
I2C_WriteTransfer(LCD_I2C_ADDR, cmd, 2, LCD_CMD, 1);
}
void lcd_set_height(uint8_t height)
{
if (height)
lcd_height = height;
}
uint8_t lcd_get_height()
{
return lcd_height;
}
void lcd_set_cursor(uint8_t pos, uint8_t type)
{
if (pos)
lcd_cursor_pos = pos;
if (type)
lcd_cursor_type = type;
}
uint8_t lcd_get_cursor_pos()
{
return lcd_cursor_pos;
}
uint8_t lcd_get_cursor_type()
{
return lcd_cursor_type;
}
void lcd_set_cgram_load(const uint8_t (*cgram)[8], const uint8_t len)
{
lcd_cgram = (uint8_t (*)[8])cgram;
lcd_cgram_len = (uint8_t)len;
}
void lcd_led_set_level(uint8_t level, uint8_t ramp_speed)
{
lcd_led_level_set = level;
lcd_led_rate = ramp_speed;
lcd_led_upd = LCD_LED_UPD_RATE;
// force an update now
lcd_led_update();
}
void lcd_led_update()
{
if (lcd_led_upd) {
lcd_led_upd--;
if (!lcd_led_upd) {
// are we done?
if (lcd_led_level == lcd_led_level_set) {
return;
}
// nope, check and see if we are increasing level
if (lcd_led_level_set > lcd_led_level) {
lcd_led_level += lcd_led_rate;
// level higher than target? then force to target
if (lcd_led_level > lcd_led_level_set) {
lcd_led_level = lcd_led_level_set;
}
}
// nope, check and see if we are decreasing level
if (lcd_led_level_set < lcd_led_level) {
// rate lower than target? if so, force to target
if ((lcd_led_level - lcd_led_level_set) > lcd_led_rate) {
lcd_led_level = lcd_led_level_set;
} else {
lcd_led_level -= lcd_led_rate;
}
}
// set OC
LCD_LED_TIMER->CCR1 = lcd_led_level;
// and reset countdown timer
lcd_led_upd = LCD_LED_UPD_RATE;
}
}
}

View File

@ -0,0 +1,72 @@
/**
* lcd.c: lcd menuing and support function prototypes
* 2014 by true
*
* ----
*
* $Id: lcd.h 327 2015-02-18 04:43:42Z true $
*
**/
#ifndef __PIRATE_DEV_LCD_H
#define __PIRATE_DEV_LCD_H
#define LCD_I2C_DEV I2C1
#define LCD_I2C_ADDR 0x3e
#define LCD_MAX_LINE_LENGTH 8 // we use an 8x2 LCD in this project
#define LCD_LED_TIMER TIM10
#define LCD_LED_OC_POLARITY TIM_OCPolarity_High
#define LCD_LED_UPD_RATE 100 // updates every 5000/100 = 50ms update rate
#define LCD_LINE_1 0x80
#define LCD_LINE_2 0xc0
#define LCD_CMD 0x00
#define LCD_DATA 0x40
#define LCD_CMD_CLEAR_SCREEN 0x01
#define LCD_CMD_SINGLEHEIGHT 0x39
#define LCD_CMD_DOUBLEHEIGHT 0x35
#define LCD_CMD_NO_CURSOR_FLASH 0x0c
#define LCD_CMD_CURSOR_FLASH 0x0d
#define LCD_CMD_CURSOR_UNDER 0x0e
#define LCD_CMD_CURSOR_UNDER_FLASH 0x0f
/* variables */
extern char lcd_line[2][9];
extern uint8_t (*lcd_cgram)[8];
extern uint8_t lcd_cgram_len;
/* prototypes */
void lcd_init();
void lcd_led_init();
void lcd_cmd(uint8_t command);
void lcd_print(uint8_t pos, uint8_t *msg, uint8_t msg_len);
void lcd_linebuf_send();
void lcd_set_contrast(uint8_t level);
void lcd_apply_contrast();
void lcd_set_height(uint8_t height);
uint8_t lcd_get_height();
void lcd_set_cursor(uint8_t pos, uint8_t type);
uint8_t lcd_get_cursor_pos();
uint8_t lcd_get_cursor_type();
void lcd_set_cgram_load(const uint8_t (*cgram)[8], const uint8_t len);
void lcd_led_set_level(uint8_t level, uint8_t ramp_speed);
void lcd_led_update();
#endif

View File

@ -0,0 +1,110 @@
/**
* lightsensor.c: control of the attiny's light sensor output plus helper functions
* 2014 true
*
* ----
*
* $Id: lightsensor.c 327 2015-02-18 04:43:42Z true $
*
**/
#include <pirate.h>
#include "lightsensor.h"
#include "attiny.h"
// light variables
uint8_t light_level;
uint8_t light_gain;
static uint8_t wait = 0;
// target brightness
// TODO: make this adjustable?
static uint8_t lev_target[5][5] = {
{0x00, 0xff, 0xe0, 0x55, 0x0d}, // skull (white)
{0x00, 0x38, 0xff, 0xff, 0xff}, // skull (purple)
{0x00, 0xff, 0xe0, 0x55, 0x0d}, // bones
{0xff, 0xff, 0xf0, 0xe0, 0xc0}, // eyes
{0x00, 0xff, 0xe0, 0x55, 0x14} // backlight
};
static uint8_t lev_set[5];
/* functions */
// gain
uint8_t lightsensor_gainvalue_update()
{
if (light_level <= settings.led_autogain_lev_min) {
if (light_gain > LIGHTSENS_GAIN_MIN) {
light_gain--;
return 1;
}
} else if (light_level >= settings.led_autogain_lev_max) {
if (light_gain < LIGHTSENS_GAIN_MAX) {
light_gain++;
return 2;
}
}
return 0;
}
// scaling
void lightsensor_scale_level(uint8_t idx)
{
int16_t scaled = 0;
uint8_t i = 5;
if (light_gain) {
if (light_gain == settings.led_autothresh[0]) {
scaled = lev_target[idx][0];
i = 1;
} else {
for (i = 1; i < 5; i++) {
if (light_gain <= settings.led_autothresh[i]) {
scaled = pirate_scale(light_gain,
settings.led_autothresh[i - 1],
settings.led_autothresh[i],
lev_target[idx][i - 1],
lev_target[idx][i]);
break;
}
}
}
if (i < 5) {
if (lev_set[idx] > scaled) {
lev_set[idx]--;
} else if (lev_set[idx] < scaled) {
lev_set[idx]++;
}
}
}
}
void lightsensor_scaler_update()
{
int i;
if (!wait) {
wait = settings.led_autoadjust & 0x7f;
for (i = 0; i < 5; i++) {
lightsensor_scale_level(i);
}
// if the scaling speed isn't set, set it fast
if (!wait) wait = 1;
}
wait--;
}
uint8_t lightsensor_get_scalerval(uint8_t which)
{
if (which <= LIGHTSENS_SCALED_BACKLIGHT) return lev_set[which]; else return 0;
}

View File

@ -0,0 +1,48 @@
/**
* lightsensor.h: control of the attiny's light sensor output plus helper functions
* 2014 true
*
* ----
*
* $Id: lightsensor.h 327 2015-02-18 04:43:42Z true $
*
**/
#ifndef __PIRATE_DEV_LIGHTSENSOR_H
#define __PIRATE_DEV_LIGHTSENSOR_H
extern uint8_t light_level;
extern uint8_t light_gain;
#define LIGHTSENS_GAIN_MIN 1 // brightest
#define LIGHTSENS_GAIN_MAX 64 // darkest
#define LIGHTSENS_AUTOGAIN_LEVEL_MIN 108 // threshold levels for gain
#define LIGHTSENS_AUTOGAIN_LEVEL_MAX 114 // should be a range of ~6-10
#define LIGHTSENS_THRESH_DAY 1
#define LIGHTSENS_THRESH_TOP_BRIGHT 4
#define LIGHTSENS_THRESH_TOP_NORM 30
#define LIGHTSENS_THRESH_TOP_DIM 48
#define LIGHTSENS_THRESH_TOP_DARK 64
#define LIGHTSENS_SCALED_SKULL_WHT 0
#define LIGHTSENS_SCALED_SKULL_PUR 1
#define LIGHTSENS_SCALED_BONES 2
#define LIGHTSENS_SCALED_EYES 3
#define LIGHTSENS_SCALED_BACKLIGHT 4
/* prototypes */
uint8_t lightsensor_gainvalue_update();
void lightsensor_scaler_update();
uint8_t lightsensor_get_scalerval(uint8_t which);
#endif

View File

@ -0,0 +1,10 @@
/**
* radio/address.c: address buffers and lookups
* 2015 by true
*
* $Id$
*
**/
static char dc22_name[32][8];
static char dc23_name[300][3];

View File

@ -0,0 +1,7 @@
/**
* radio/address.h: address buffers and lookups
* 2015 by true
*
* $Id$
*
**/

View File

@ -0,0 +1,15 @@
/**
* radio/irq.c: nrf irq handler
* 2015 by true
* ----
*
* $Id$
*
**/
#include <pirate.h>
#include "nrf.h"

View File

@ -0,0 +1,142 @@
/**
* radio/nrf.c: interface to radiowaves
* 2015 by true
*
* ----
*
* This is a nasty hack implementation of the NRF24L01+.
* Modify as necessary if using on another STM32; see nrf.h
* and the NRF24L01 library.
*
* ----
*
* $Id: nrf.c 375 2015-07-06 02:52:40Z true $
*
**/
#include <pirate.h>
#include "nrf.h"
/* variables */
// general radio
uint8_t nrf_detected;
uint8_t nrf_myaddr;
static uint8_t nrf_tx_addr[5] = {0x00, '8', 'r', 'i', 'P'};
uint8_t nrf_tx_buf[NRF_PAYLOAD_LEN];
static uint8_t nrf_rx_addr_p0[5] = {0x00, '8', 'r', 'i', 'P'};
static uint8_t nrf_rx_addr_p1[5] = {0x01, '8', 'r', 'i', 'P'};
// pingpong
uint8_t nrf_last_ping_id; // sender's last byte
uint8_t nrf_last_ping_idx; // index byte
// encryption
static uint32_t xxtea_key[2][4];
static uint8_t xxtea_key_done[2];
/* functions */
uint8_t nrf_checksum(uint8_t *data, uint8_t len, int32_t offset) {
int32_t ret = 0;
while (len) {
ret += *data++;
len--;
}
return (ret + offset);
}
void nrf_process_data(uint8_t pipe, uint8_t *pBuf, uint8_t len)
{
int32_t w = 0;
if (len != NRF_PAYLOAD_LEN) return;
// first see if there are any unencrypted commands
// TODO: verify checksum to see if packet is valid
switch (pBuf[0]) {
case NRF_CMD_GETKEY: {
// check to see if the message is formatted correctly
// we will oblige and send out the keys we have
// TODO: send key
break;
}
case NRF_CMD_SETKEY: {
// check to see if the message is formatted correctly
// we are a DC22 badge, so we have the keys already
break;
}
case NRF_CMD_PING: {
// get received address for this packet
nrf_last_ping_id = pipe;
// and pull the index
nrf_last_ping_idx = pBuf[2];
return;
}
}
// decode with dc22 public key and see if checksum matches
if (xxtea_key_done[0]) {
btea((uint32_t *)pBuf, -2, xxtea_key[0]);
if (!nrf_checksum(pBuf, 7, pBuf[7])) {
w = 22;
}
}
// decode with dc22 shared key and see if it matches
if (xxtea_key_done[1] && !w) {
btea((uint32_t *)pBuf, -2, xxtea_key[1]);
if (!nrf_checksum(pBuf, 7, pBuf[7])) {
w = 23;
}
}
// try to process this data
if (w) {
// yes, we can
// TODO: process radio data
switch (pBuf[0]) {
}
}
}
void nrf_init()
{
// initialize nRF24 library
nRF24_init(SystemCoreClock);
// clear any pending interrupts, we don't give a shit about them
nRF24_clear_irq_flags();
// set nrf data callbacks
nRF24_rx_cb = nrf_process_data;
nrf_myaddr = *(uint8_t *)NRF_MYADDR_EEPROM;
nrf_detected = 0;
if (nRF24_is_present()) {
nrf_detected = 1;
}
// and finally, configure the radio and turn it on in listen mode
nRF24_set_payload_size(0, NRF_PAYLOAD_LEN);
nRF24_set_payload_size(1, NRF_PAYLOAD_LEN);
nRF24_set_autoack(1, 0); // no autoack on general receive pipe
nRF24_set_dynack(1); // allows us to NO_ACK packets
nRF24_update_config(_TRNRF_UPDATE_ALL);
nRF24_set_txaddr(nrf_tx_addr);
nRF24_set_rxaddr(0, nrf_rx_addr_p0);
nRF24_set_rxaddr(1, nrf_rx_addr_p1);
nRF24_mode_rx();
}

View File

@ -0,0 +1,54 @@
/**
* radio/nrf.h: interface to radiowaves prototypes
* 2015 by true
*
* ----
*
* $Id: nrf.h 505 2021-09-05 19:07:51Z true $
*
**/
#ifndef __PIRATE_DEV_NRF24L01_H
#define __PIRATE_DEV_NRF24L01_H
/* libraries */
#include "nrf24l01/true_nRF24L01.h"
#include <xxtea.h>
/* defines */
#define NRF_PAYLOAD_LEN 8 // 1 byte command, 1 byte class, 1 byte byte index, 4 bytes data, 1 byte checksum
#define NRF_MYADDR_EEPROM (uint32_t)0x080807fc // 4 bytes, only using highest byte right now
/* commands (main channel) */
#define NRF_CMD_GETKEY 0x00 // TODO: devices query for a key until they get one
#define NRF_CMD_SETKEY 0x01 // TODO: sends a key for devices to use
#define NRF_CMD_REQ_SUBADDR 0x08 // TODO: asks for subaddress in use
#define NRF_CMD_PAGEDC22 0x19 // TODO: pages a dc22-style badge, index is block num, 3 blocks to send, 8 char name, 4 char nonce. index >=0x80 = direct
#define NRF_CMD_PAGEDC23 0x1a // TODO: pages a dc23-style badge, index is block num, 2 blocks to send, 3 char name, 4 char nonce. index >=0x80 = direct
#define NRF_CMD_MUSICNOTES 0x40 // TODO: queues and plays the desired music notes. 2 bytes per note, one for note to play (or start play cmd), one for duration of note
#define NRF_CMD_MUSICLIBRARY 0x42 // TODO: queues playing a song from the music library. if index = 0xff, badges will repeat with countdown information.
#define NRF_CMD_ANIMATION 0x8D
#define NRF_CMD_DC22_23GREET 0x8F
#define NRF_CMD_PING 0x91 // TODO: sends ping. dest waits the amount of milliseconds of its ID times two before responding. index is this badge's P1
#define NRF_CMD_PONG 0x92 // TODO: reply sent to target in response to ping. sends to P1 as specified in ping.
/* variables */
extern uint8_t nrf_detected;
extern uint8_t nrf_myaddr;
extern uint8_t nrf_tx_buf[NRF_PAYLOAD_LEN];
extern uint8_t nrf_last_ping_id; // sender's last byte
extern uint8_t nrf_last_ping_idx; // index byte
/* prototypes */
void nrf_init();
uint8_t nrf_checksum(uint8_t *data, uint8_t len, int32_t offset);
#endif

View File

@ -0,0 +1,186 @@
/* nRF24L01.h
* Register definitions for manipulating the Nordic Semiconductor
* nRF24L01+ RF transceiver chipsets.
*
Copyright (c) 2007 Stefan Engelke <mbox@stefanengelke.de>
Some parts copyright (c) 2012 Eric Brundick <spirilis [at] linux dot com>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef _NRF24L01_H
#define _NRF24L01_H
#define NRF_BIT0 1 << 0
#define NRF_BIT1 1 << 1
#define NRF_BIT2 1 << 2
#define NRF_BIT3 1 << 3
#define NRF_BIT4 1 << 4
#define NRF_BIT5 1 << 5
#define NRF_BIT6 1 << 6
#define NRF_BIT7 1 << 7
/* Register Map */
#define RF24_CONFIG 0x00 // Configuration register
#define RF24_EN_AA 0x01 // Enable "Auto acknowledgment"
#define RF24_EN_RXADDR 0x02 // Enable RX addresses
#define RF24_SETUP_AW 0x03 // Setup of address widths
#define RF24_SETUP_RETR 0x04 // Setup of automatic retranslation
#define RF24_RF_CH 0x05 // RF channel
#define RF24_RF_SETUP 0x06 // RF setup register
#define RF24_STATUS 0x07 // Status register
#define RF24_OBSERVE_TX 0x08 // Transmit observe register
#define RF24_CD 0x09 // Carrier detect
#define RF24_RPD 0x09
#define RF24_RX_ADDR_P0 0x0A // Receive address data pipe 0
#define RF24_RX_ADDR_P1 0x0B // ..
#define RF24_RX_ADDR_P2 0x0C // ..
#define RF24_RX_ADDR_P3 0x0D // ..
#define RF24_RX_ADDR_P4 0x0E // ..
#define RF24_RX_ADDR_P5 0x0F // Receive address data pipe 5
#define RF24_TX_ADDR 0x10 // Transmit address
#define RF24_RX_PW_P0 0x11 // Number of bytes in RX payload id data pipe 0
#define RF24_RX_PW_P1 0x12 // ..
#define RF24_RX_PW_P2 0x13 // ..
#define RF24_RX_PW_P3 0x14 // ..
#define RF24_RX_PW_P4 0x15 // ..
#define RF24_RX_PW_P5 0x16 // Number of bytes in RX payload id data pipe 5
#define RF24_FIFO_STATUS 0x17 // FIFO status register
#define RF24_DYNPD 0x1C // Enable dynamic payload length
#define RF24_FEATURE 0x1D // Feature register
/* Register NRF_BITs */
#define RF24_MASK_RX_DR NRF_BIT6 // Mask interrupt caused by RX_DR
#define RF24_MASK_TX_DS NRF_BIT5 // Mask interrupt caused by TX_DS
#define RF24_MASK_MAX_RT NRF_BIT4 // Mask interrupt caused by MAX_RT
#define RF24_EN_CRC NRF_BIT3
#define RF24_CRCO NRF_BIT2
#define RF24_PWR_UP NRF_BIT1
#define RF24_PRIM_RX NRF_BIT0
#define RF24_ENAA_P5 NRF_BIT5
#define RF24_ENAA_P4 NRF_BIT4
#define RF24_ENAA_P3 NRF_BIT3
#define RF24_ENAA_P2 NRF_BIT2
#define RF24_ENAA_P1 NRF_BIT1
#define RF24_ENAA_P0 NRF_BIT0
#define RF24_ERX_P5 NRF_BIT5
#define RF24_ERX_P4 NRF_BIT4
#define RF24_ERX_P3 NRF_BIT3
#define RF24_ERX_P2 NRF_BIT2
#define RF24_ERX_P1 NRF_BIT1
#define RF24_ERX_P0 NRF_BIT0
#define RF24_DYNPL_P5 NRF_BIT5
#define RF24_DYNPL_P4 NRF_BIT4
#define RF24_DYNPL_P3 NRF_BIT3
#define RF24_DYNPL_P2 NRF_BIT2
#define RF24_DYNPL_P1 NRF_BIT1
#define RF24_DYNPL_P0 NRF_BIT0
#define RF24_AW NRF_BIT0
#define RF24_ARD NRF_BIT4
#define RF24_ARC NRF_BIT0
#define RF24_PLL_LOCK NRF_BIT4
#define RF24_CONT_WAVE NRF_BIT7
#define RF24_RF_DR NRF_BIT3
#define RF24_RF_DR_LOW NRF_BIT5
#define RF24_RF_DR_HIGH NRF_BIT3
#define RF24_RF_PWR NRF_BIT1
#define RF24_LNA_HCURR NRF_BIT0
#define RF24_RX_DR NRF_BIT6
#define RF24_TX_DS NRF_BIT5
#define RF24_MAX_RT NRF_BIT4
#define RF24_RX_P_NO NRF_BIT1
#define RF24_TX_FULL NRF_BIT0
#define RF24_PLOS_CNT NRF_BIT4
#define RF24_ARC_CNT NRF_BIT0
#define RF24_TX_REUSE NRF_BIT6
#define RF24_FIFO_FULL NRF_BIT5
#define RF24_TX_EMPTY NRF_BIT4
#define RF24_RX_FULL NRF_BIT1 // RX FIFO full flag
#define RF24_RX_EMPTY NRF_BIT0 // RX FIFO empty flag
#define RF24_EN_DPL NRF_BIT2
#define RF24_EN_ACK_PAY NRF_BIT1
#define RF24_EN_DYN_ACK NRF_BIT0
#define RF24_SPEED_250 NRF_BIT5
#define RF24_SPEED_1000 0
#define RF24_SPEED_2000 NRF_BIT3
#define RF24_POWER_FULL NRF_BIT2 | NRF_BIT1
#define RF24_POWER_HIGH NRF_BIT2
#define RF24_POWER_MED NRF_BIT1
#define RF24_POWER_LOW 0
#define RF24_RETRY_250US 0x00
#define RF24_RETRY_500US 0x10
#define RF24_RETRY_750US 0x20
#define RF24_RETRY_1000US 0x30
#define RF24_RETRY_1250US 0x40
#define RF24_RETRY_1500US 0x50
#define RF24_RETRY_1750US 0x60
#define RF24_RETRY_2000US 0x70
#define RF24_RETRY_2250US 0x80
#define RF24_RETRY_2500US 0x90
#define RF24_RETRY_2750US 0xa0
#define RF24_RETRY_3000US 0xb0
#define RF24_RETRY_3250US 0xc0
#define RF24_RETRY_3500US 0xd0
#define RF24_RETRY_3750US 0xe0
#define RF24_RETRY_4000US 0xf0
#define RF24_RETRANS_OFF 0
#define RF24_RETRANS_1X 1
#define RF24_RETRANS_2X 2
#define RF24_RETRANS_3X 3
#define RF24_RETRANS_4X 4
#define RF24_RETRANS_5X 5
#define RF24_RETRANS_6X 6
#define RF24_RETRANS_7X 7
#define RF24_RETRANS_8X 8
#define RF24_RETRANS_9X 9
#define RF24_RETRANS_10X 10
#define RF24_RETRANS_11X 11
#define RF24_RETRANS_12X 12
#define RF24_RETRANS_13X 13
#define RF24_RETRANS_14X 14
#define RF24_RETRANS_15X 15
/* Instructions */
#define RF24_RREG 0x00 // R_REGISTER -> Read command and status registers
#define RF24_WREG 0x20 // W_REGISTER -> Write command and status registers
#define RF24_REGISTER_MASK 0x1F
#define RF24_R_RX_PAYLOAD 0x61 // R_RX_PAYLOAD -> Read RX payload
#define RF24_W_TX_PAYLOAD 0xA0 // W_TX_PAYLOAD -> Write TX payload
#define RF24_FLUSH_TX 0xE1 // FLUSH_TX -> Flush TX FIFO
#define RF24_FLUSH_RX 0xE2 // FLUSH_RX -> Flush RX FIFO
#define RF24_REUSE_TX_PL 0xE3 // REUSE_TX_PL -> Reuse last transmitted payload
#define RF24_R_RX_PL_WID 0x60
#define RF24_W_ACK_PAYLOAD 0xA8
#define RF24_W_TX_PAYLOAD_NOACK 0xB0
#define RF24_ACTIVATE 0x50
#define RF24_NOP 0xFF // No operation (to read status register)
#endif

View File

@ -0,0 +1,766 @@
/*
* true's NRF24L01+ C library
* shamelessly stolen and modified heavily from some other shit
* basically: it's better than nothing
*
* $Id: true_nRF24L01.c 505 2021-09-05 19:07:51Z true $
* ====
*
* general instructions to set up:
* - Edit any shit necessary for your driver to work, update "true_nRF24L01.h"
* with your driver include file
* - #include "true_nRF24L01.h" in your radio setup code source file
* - for RX devices, you should set nRF24_rx_cb to your data handler. this
* handler is called with the data buffer / buffer length and received pipe.
* - call nRF24_init() which sets defaults, calls nRF24_driver_init() which
* sets up hardware tasks, peripherals, and interrupts
* - set and update your configuration, tx/rx addresses in your code
* - in your IRQ pin ISR, call nRF24_interrupt(). this might be in your driver.
* - if you did not set nRF24_rx_cb, check for new data by reading status
* and RX FIFO, and receive data manually however you decide to do it
* - no special shit for transmit, just set up and go
*/
/* nrf24 library includes */
#include "true_nRF24L01.h"
/* nrf24 configuration */
static uint32_t txdelay;
static nrfConfig config;
/* nrf24 data handling */
static uint8_t nRF24_pbuf[_TRNRF_MAX_PACKET_SIZE];
void (*nRF24_rx_cb)(uint8_t pipe, uint8_t *pBuf, uint8_t len);
void (*nRF24_tx_done_cb)();
void (*nRF24_tx_max_rt_cb)();
/* nrf24 feedback */
static uint8_t nrf_mode = _TRNRF_MODE_OFF;
static uint8_t rx_received_pipe;
/*********************************/
/**** NRF SETUP AND INTERRUPT ****/
/**
* Initializes nRF24 config and hardware layer abstracted shit.
*/
void nRF24_init(uint32_t cpu_freq_hz) {
// TX pin delay factor
txdelay = cpu_freq_hz >> 19;
// set some defaults
config.channel = 2;
config.rate_power = RF24_SPEED_1000 | RF24_POWER_FULL;
config.addr_width = 5;
config.payload_size[0] = 8;
config.payload_size[1] = 8;
config.crc = RF24_EN_CRC | RF24_CRCO;
config.pipe_ena = RF24_ERX_P0 | RF24_ERX_P1; // this is NRF power-up default
config.autoack_ena = 0x3f; // this is NRF power-up default
config.retry = RF24_RETRY_500US | RF24_RETRANS_10X;
config.tx_config = _TRNRF_MAX_RT_AUTOFLUSH | _TRNRF_MODE_RX;
// start up the hardware shit
nRF24_driver_init();
// clear the RX/TX FIFOs
nRF24_reg_write(RF24_FLUSH_RX);
nRF24_reg_write(RF24_FLUSH_TX);
// and clear interrupt sources
nRF24_clear_irq_flags();
}
/* Note: at this time, this code requires the IRQ pin to operate */
/**
* Handles doing shit (receive data, clear IRQ flags) when IRQ is asserted.
*
* Call this function from your IRQ handler.
*
* @return NRF status
*/
uint8_t nRF24_interrupt()
{
uint8_t status;
uint8_t pipe;
uint8_t len;
status = nRF24_reg_write(RF24_NOP);
if (status & RF24_TX_DS) {
// packet sent successfully and should not be in our FIFO
if (nRF24_tx_done_cb != 0) {
nRF24_tx_done_cb();
}
}
if (status & RF24_MAX_RT) {
// packet not sent successfully and IS still in our FIFO
if (config.tx_config & _TRNRF_MAX_RT_AUTOFLUSH) {
nRF24_reg_write(RF24_FLUSH_TX);
}
if (nRF24_tx_max_rt_cb != 0) {
nRF24_tx_max_rt_cb();
}
}
if (status & RF24_RX_DR) {
// process data
if ((status & RF24_RX_P_NO) == RF24_RX_P_NO) {
// fifo done interrupt, so what? we don't care
} else {
if (nRF24_data_is_ready()) {
// looks like we have some data waiting for us
// if no callback is set, assume we are handling this manually elsewhere
if (nRF24_rx_cb != 0) {
// but our callback is set, so receive data
len = nRF24_packet_rx(status, nRF24_pbuf);
pipe = nRF24_rx_received_pipe();
// process data
if (len <= _TRNRF_MAX_PACKET_SIZE) {
nRF24_rx_cb(pipe, nRF24_pbuf, len);
}
}
}
}
}
// clear all pending interrupt flags
nRF24_clear_irq_flags();
// resume wtf we needed to do
if (nrf_mode & _TRNRF_MODE_TX) {
switch (config.tx_config & _TRNRF_MODE_MASK) {
case _TRNRF_MODE_RX: {
nRF24_mode_rx();
break;
}
case _TRNRF_MODE_OFF: {
nRF24_mode_off();
break;
}
case _TRNRF_MODE_TX: {
// this will put us into standby-ii. this mode is not recommended.
_TRNRF_CE_H();
break;
}
}
} else if (nrf_mode & _TRNRF_MODE_RX) {
nRF24_mode_rx();
}
return status;
}
/***************************/
/**** NRF SPI FUNCTIONS ****/
/**
* Writes a value to NRF register or a single-byte argument to a command,
* and reads the following byte (usually the result, see the datasheet)
*
* @param reg register / command to write to
* @param value value to write to register / command
*
* @return value of the STATUS register
*/
uint8_t nRF24_reg_rw(uint8_t reg, uint8_t value) {
uint8_t status;
_TRNRF_CSN_L();
status = nRF24_spi_rw(reg); // Select register/command
nRF24_spi_rw(value); // Write value to register
_TRNRF_CSN_H();
return status;
}
/**
* Writes a command byte to the NRF, and returns STATUS.
*
* @param cmd command to write
*
* @return value of the STATUS register
*/
uint8_t nRF24_reg_write(uint8_t cmd) {
uint8_t status;
_TRNRF_CSN_L();
status = nRF24_spi_rw(cmd);
_TRNRF_CSN_H();
return status;
}
/**
* Reads a byte from the NRF register or command.
*
* @param reg register / command to read from
*
* @return value of this register / command
*/
uint8_t nRF24_reg_read(uint8_t reg) {
uint8_t value;
_TRNRF_CSN_L();
nRF24_spi_rw(reg);
value = nRF24_spi_rw(0x00);
_TRNRF_CSN_H();
return value;
}
/**
* Writes a buffer to NRF.
*
* @param reg register (buffer) to write info
* @param *pBuf source buffer contents to read from
* @param len bytes to read
*
* @return value of the STATUS register
*/
uint8_t nRF24_buf_write(uint8_t reg, void *pBuf, uint8_t bytes) {
uint8_t status;
uint8_t i;
_TRNRF_CSN_L();
status = nRF24_spi_rw(reg);
for (i = 0; i < bytes; i++)
nRF24_spi_rw(((uint8_t *)pBuf)[i]);
_TRNRF_CSN_H();
return status;
}
/**
* Reads a buffer from NRF.
*
* @param reg register (buffer) to read from
* @param *pBuf buffer to read register into
* @param bytes bytes to read
*
* @return value of the STATUS register
*/
uint8_t nRF24_buf_read(uint8_t reg, void *pBuf, uint8_t bytes) {
uint8_t status;
uint8_t i;
_TRNRF_CSN_L();
status = nRF24_spi_rw(reg);
for (i = 0; i < bytes; i++)
((uint8_t *)pBuf)[i] = nRF24_spi_rw(0x00);
_TRNRF_CSN_H();
return status;
}
/***********************************/
/**** NRF USER CONFIG FUNCTIONS ****/
/**
* Updates the TX address to the radio.
*/
void nRF24_update_txaddr()
{
_TRNRF_CE_L();
if (config.tx_addr) {
nRF24_buf_write(RF24_WREG | RF24_TX_ADDR, config.tx_addr, config.addr_width);
}
// were we in RX mode? yeah? then start listening again
if ((nrf_mode & _TRNRF_MODE_MASK) == _TRNRF_MODE_RX) {
_TRNRF_CE_H();
}
}
/**
* Sets the TX address buffer pointer, and updates the radio with this address.
* Make sure this buffer is at least config.addr_width in size.
*
* @param *addr pointer to tx buffer
*/
void nRF24_set_txaddr(const uint8_t *addr)
{
config.tx_addr = (uint8_t *)addr;
nRF24_update_txaddr();
}
/**
* Updates the specified RX address to the radio.
*
* Please remember, auto-acknowledge requires pipe 0's address to match the
* transmit address.
*
* Please remember, pipes 2 through 5 copy pipe 1's most significant bytes.
*/
void nRF24_update_rxaddr(uint8_t pipe)
{
_TRNRF_CE_L();
if (pipe == 0 && config.rx_addr_p0) {
nRF24_buf_write(RF24_WREG | RF24_RX_ADDR_P0, config.rx_addr_p0, config.addr_width);
} else if (pipe == 1 && config.rx_addr_p1) {
nRF24_buf_write(RF24_WREG | RF24_RX_ADDR_P1, config.rx_addr_p1, config.addr_width);
} else if (pipe <= 5) {
nRF24_reg_rw(RF24_WREG | (RF24_RX_ADDR_P0 + pipe), config.rx_pipe[pipe - 2]);
}
// were we in RX mode? yeah? then start listening again
if ((nrf_mode & _TRNRF_MODE_MASK) == _TRNRF_MODE_RX) {
_TRNRF_CE_H();
}
}
/**
* Sets the RX address buffer pointer for pipes 0 and 1, and sets the
* unique byte for pipes 2 through 5. Afterwards, updates the radio
* with the new address.
*
* For pipes 0 and 1, make sure this buffer is at least config.addr_width in size.
*
* @param *addr pointer to rx buffer (can be temporary for pipes 2 through 5)
*/
void nRF24_set_rxaddr(uint8_t pipe, const uint8_t *addr)
{
if (pipe == 0) {
config.rx_addr_p0 = (uint8_t *)addr;
} else if (pipe == 1) {
config.rx_addr_p1 = (uint8_t *)addr;
} else if (pipe <= 5) {
config.rx_pipe[pipe - 2] = *addr;
}
nRF24_update_rxaddr(pipe);
}
/**
* Sets the active channel between 2400MHz (0) and 2.525MHz (125).
* At 2Mbps channel width is larger than 1MHz, so use 2MHz spacings
* if you have multiple channels with multiple devices in use.
*/
void nRF24_set_channel(uint8_t chan)
{
if (chan > 125) chan = 125;
config.channel = chan;
}
/**
* Sets the data rate between RF_SPEED_250, RF_SPEED_1000, and RF_SPEED_2000.
*/
void nRF24_set_rate(uint8_t rate)
{
config.rate_power &= ~(RF24_SPEED_250 | RF24_SPEED_1000 | RF24_SPEED_2000);
config.rate_power |= (rate & (RF24_SPEED_250 | RF24_SPEED_1000 | RF24_SPEED_2000));
}
/**
* Sets the output power level.
*/
void nRF24_set_power(uint8_t power)
{
config.rate_power &= ~(RF24_POWER_FULL);
config.rate_power |= (power & (RF24_POWER_FULL));
}
/**
* Sets the address width from 3 to 5 bytes wide.
*/
void nRF24_set_addr_width(uint8_t width)
{
if (width < 3) width = 3;
if (width > 5) width = 5;
config.addr_width = width;
}
/**
* Sets the payload size.
*/
void nRF24_set_payload_size(uint8_t pipe, uint8_t size)
{
if (pipe <= 5) {
config.payload_size[pipe] = size;
}
}
/**
* Sets the CRC options.
*/
void nRF24_set_crc(uint8_t crc)
{
config.crc = crc & (RF24_EN_CRC | RF24_CRCO);
}
/**
* Enables and disables receive pipes.
*/
void nRF24_set_pipe(uint8_t pipe, uint8_t onoff)
{
if (pipe <= 5) {
if (onoff) {
config.pipe_ena |= (1 << pipe);
} else {
config.pipe_ena &= ~(1 << pipe);
}
}
}
/**
* Enables and disables Shockburst (auto-acknowledge) per pipe.
*/
void nRF24_set_autoack(uint8_t pipe, uint8_t onoff)
{
if (pipe <= 5) {
if (onoff) {
config.autoack_ena |= (1 << pipe);
} else {
config.autoack_ena &= ~(1 << pipe);
}
}
}
/**
* Enables or disables the Dynamic ACK transmit option.
*/
void nRF24_set_dynack(uint8_t onoff)
{
if (onoff) {
config.autoack_ena |= 0x80;
} else {
config.autoack_ena &= 0x7f;
}
}
/**
* Sends the active configuration to the radio.
*/
void nRF24_update_config(uint8_t mask)
{
uint8_t set[3];
uint8_t bit;
uint8_t i;
set[0] = set[1] = set[2] = 0;
_TRNRF_CE_L();
// set SETUP_AW address width
if (mask & _TRNRF_UPDATE_SETUP_AW) {
nRF24_reg_rw(RF24_WREG | RF24_SETUP_AW, config.addr_width - 2);
}
// set up various per-pipe configurations
if (mask & (_TRNRF_UPDATE_EN_RXADDR | _TRNRF_UPDATE_EN_AA | _TRNRF_UPDATE_DYNPD | _TRNRF_UPDATE_FEATURE)) {
for (i = 0; i <= 5; i++) {
bit = 1 << i;
if (config.pipe_ena & bit) {
set[0] |= bit;
nRF24_reg_rw(RF24_WREG | (RF24_RX_PW_P0 + i),
(config.payload_size[i] > 32 ? 32 : config.payload_size[i]));
}
if (config.autoack_ena & bit) {
set[1] |= bit;
}
if (config.payload_size[i] == _TRNRF_DYN_PAYLOAD) {
set[2] |= bit;
}
}
if (mask & _TRNRF_UPDATE_EN_AA) nRF24_reg_rw(RF24_WREG | RF24_EN_AA, set[1]);
if (mask & _TRNRF_UPDATE_EN_RXADDR) nRF24_reg_rw(RF24_WREG | RF24_EN_RXADDR, set[0]);
if (mask & (_TRNRF_UPDATE_DYNPD | _TRNRF_UPDATE_FEATURE)) {
nRF24_reg_rw(RF24_WREG | RF24_DYNPD, set[2]);
// set up FEATURE register (dynamic payload length, ack payload, dynamic ack [noack])
set[0] = ((set[2] ? RF24_EN_DPL : 0) | ((config.autoack_ena & 0x80) ? RF24_EN_DYN_ACK : 0));
nRF24_reg_rw(RF24_WREG | RF24_FEATURE, set[0]);
}
}
// set SETUP_RETR auto-ack retry settings
if (mask & _TRNRF_UPDATE_SETUP_RETR) {
nRF24_reg_rw(RF24_WREG | RF24_SETUP_RETR, config.retry);
}
// set RF_CH channel
if (mask & _TRNRF_UPDATE_RF_CH) {
nRF24_reg_rw(RF24_WREG | RF24_RF_CH, config.channel);
}
// set RF_SETUP data rate, power output
if (mask & _TRNRF_UPDATE_RF_SETUP) {
nRF24_reg_rw(RF24_WREG | RF24_RF_SETUP, config.rate_power);
}
// set CONFIG crc
if (mask & _TRNRF_UPDATE_CRC) {
set[0] = nRF24_reg_read(RF24_CONFIG) & (RF24_PWR_UP | RF24_PRIM_RX);
nRF24_reg_rw(RF24_WREG | RF24_CONFIG, config.crc | set[0]);
}
// were we in RX mode? yeah? then start listening again
if ((nrf_mode & _TRNRF_MODE_MASK) == _TRNRF_MODE_RX) {
_TRNRF_CE_H();
}
}
/**
* Sets the state to go into after transmit is done.
* This mode is applied after a TX is complete in the interrupt handler.
*/
void nRF24_set_tx_config(uint8_t max_rt_flush, uint8_t new_done_state)
{
config.tx_config = (max_rt_flush & 0x80) | (new_done_state & 0x7f);
}
/**
* Checks to see if an NRF24L01 is present by setting and reading a fake address.
* After completion, it resets to the configured address parameters.
*
* @return nRF24 is present (1 = yes, 0 = no)
*/
uint8_t nRF24_is_present(void) {
uint8_t buf[3];
// write address length and fake address
buf[2] = 0xa9;
nRF24_reg_rw(RF24_WREG | RF24_SETUP_AW, 0x01); // 3 bytes
nRF24_buf_write(RF24_WREG | RF24_TX_ADDR, buf, 3);
// clear some address data
buf[2] = 0x00;
// try to read TX_ADDR register back
nRF24_buf_read(RF24_TX_ADDR, buf, 3);
// reset SETUP_AW and TX addr
nRF24_reg_rw(RF24_WREG | RF24_SETUP_AW, config.addr_width - 2);
nRF24_update_txaddr();
// verify address matches fake address
if (buf[2] == 0xa9)
return 1;
// seems to be missing...
return 0;
}
/*************************/
/**** OPERATING MODES ****/
/**
* Puts the NRF into RX mode, turns on the radio, and starts listening.
*
* Only sets registers necessary to do this. Configure the radio
* with nRF24_update_rxaddr, nRF24_update_config before putting
* it into RX mode.
*/
void nRF24_mode_rx() {
_TRNRF_CE_L();
nRF24_reg_rw(RF24_WREG | RF24_CONFIG, config.crc | RF24_PWR_UP | RF24_PRIM_RX);
// put into active receive mode immediately
_TRNRF_CE_H();
nrf_mode = _TRNRF_MODE_RX;
}
/**
* Prepares for standby, then puts the NRF into TX mode and turns on the radio.
*
* This is called from nRF24_packet_tx() automatically if the mode is
* currently not in a transmit mode. Transmit will occur when
* nRF24_packet_tx() is used.
*
* Only sets registers necessary to complete changing the mode. Configure any
* other settings for the radio with nRF24_update_rxaddr (if auto-ack is on),
* nRF24_update_txaddr, nRF24_update_config before putting it into TX mode.
*/
void nRF24_mode_tx() {
// we will set high when ready to transmit
_TRNRF_CE_L();
nRF24_reg_rw(RF24_WREG | RF24_CONFIG, config.crc | RF24_PWR_UP);
nrf_mode = _TRNRF_MODE_TX;
}
/**
* Puts the radio into standby (useful when in RX mode to save power).
*/
void nRF24_mode_standby()
{
_TRNRF_CE_L();
nrf_mode |= _TRNRF_MODE_STANDBY;
}
/**
* Powers down the NRF24L01.
*/
void nRF24_mode_off()
{
_TRNRF_CE_L();
nRF24_reg_rw(RF24_WREG | RF24_CONFIG, nRF24_reg_read(RF24_CONFIG) & ~(RF24_PWR_UP));
nrf_mode = _TRNRF_MODE_OFF;
}
/**
* Returns the currently operating NRF mode.
*/
uint8_t nRF24_mode_get()
{
return nrf_mode;
}
/**************************/
/**** DATA TRANSCIEVER ****/
/**
* Checks if data is ready by seeing if there is anything in the RX FIFO.
*/
uint8_t nRF24_data_is_ready(void) {
uint8_t status;
status = nRF24_reg_read(RF24_FIFO_STATUS);
return (status & RF24_RX_EMPTY) ? 0 : 1;
}
/**
* Loads a packet for transmit, puts the radio into transmit mode, then signals
* radio to begin transmitting.
*
* @param *pBuf pointer to transmit buffer
* @param bytes bytes to send
* @param noack if not zero, and if dynack enabled, flags the packet NO_ACK
*/
void nRF24_packet_tx(void *pBuf, uint8_t bytes, uint8_t noack) {
int i;
// make sure we are in TX mode
if ((nrf_mode & _TRNRF_MODE_TX) == 0) {
nRF24_mode_tx();
}
// write TX buffer to FIFO
// note: noack mode will only work if nRF24_set_dynack(1); nRF24_config_update(); has been done
// also make sure that you have nRF24_set_rxaddr(0, txaddr) if using shockburst
nRF24_buf_write((noack && config.autoack_ena & 0x80) ?
RF24_W_TX_PAYLOAD_NOACK : RF24_W_TX_PAYLOAD, pBuf, bytes);
// CE pin high => start transmit
_TRNRF_CE_H();
// if we're going into standard standby-I mode, need to do a little more
if (!(config.tx_config & _TRNRF_MODE_TX)) {
// needs to be high for at least 10us for tx to function, per datasheet
// this keeps it high for about 16us
for (i = txdelay; i; i--) {
asm volatile ("nop");
}
_TRNRF_CE_L();
}
}
/**
* Receives a packet.
*
* @param status nRF24 status (please get with nRF24_reg_read(RF24_STATUS))
* @param *pBuf pointer to receive buffer
*
* @return length of data received
*/
int8_t nRF24_packet_rx(uint8_t status, void *pBuf) {
uint8_t pipe;
uint8_t payload_len;
// status must indicate RX ready and RX FIFO not empty
if ((status & RF24_RX_DR) && ((status & RF24_RX_P_NO) != RF24_RX_P_NO)) {
// get pipe
pipe = (status & RF24_RX_P_NO) >> 1;
// payload is static, unless it isn't, in which case get the received payload length
payload_len = config.payload_size[pipe];
if (payload_len == _TRNRF_DYN_PAYLOAD) {
payload_len = nRF24_reg_read(RF24_R_RX_PL_WID);
// is it valid?
if (payload_len > 32) {
// no, flush buffer and quit
nRF24_reg_write(RF24_FLUSH_RX);
return -1;
}
}
// everything else done, so set pipe, clear buffer, read payload from RX FIFO buffer
// NRF automatically removes this data from FIFO per datasheet
rx_received_pipe = pipe;
nRF24_buf_read(RF24_R_RX_PAYLOAD, pBuf, payload_len);
return payload_len;
}
// requests to receive that are not ready will clear RX FIFO
nRF24_reg_write(RF24_FLUSH_RX);
return -2;
}
/**
* Returns the last received data's pipe number.
*/
uint8_t nRF24_rx_received_pipe()
{
return rx_received_pipe;
}
uint8_t nRF24_packet_ackreply(uint8_t *pBuf, uint8_t tx_payload_len)
{
if (config.payload_size[0] != _TRNRF_DYN_PAYLOAD) {
// ack reply payloads require dynamic payload to be enabled
return 0;
}
// not yet implemented
return 1;
}
/*****************/
/**** IRQ PIN ****/
/**
* Clear all IRQ status flags.
*/
void nRF24_clear_irq_flags(void) {
// Clear RX_DR, TX_DS, MAX_RT flags. cleared by writing 1 to these bits
nRF24_reg_rw(RF24_WREG | RF24_STATUS, (RF24_RX_DR | RF24_TX_DS | RF24_MAX_RT));
}

View File

@ -0,0 +1,128 @@
/*
* true's NRF24L01+ C library
* shamelessly stolen and modified heavily from some other shit
* basically: it's better than nothing
*
* $Id: true_nRF24L01.h 505 2021-09-05 19:07:51Z true $
*/
#ifndef __TRUE_NRF24L01_LIB_H
#define __TRUE_NRF24L01_LIB_H
/* common libraries */
#include <stdint.h>
#include "nRF24L01.h"
/* user compile-time configuration */
#define _TRNRF_MAX_PACKET_SIZE 32 // 32 is the max the radio can handle
// set lower to save memory
/* platform driver select */
#include "true_nRF24L01_stm32l1xx.h"
/* compile-time user configuration */
#define _TRNRF_USE_INTERRUPT_PIN // enables the use of interrupt pin
// only interrupt-mode implemented, currently mandatory
/* nrf library constants */
#define _TRNRF_MODE_OFF 0x00
#define _TRNRF_MODE_STANDBY 0x01
#define _TRNRF_MODE_RX 0x10
#define _TRNRF_MODE_TX 0x20
#define _TRNRF_MODE_MASK 0x3f
#define _TRNRF_UPDATE_ALL 0xff
#define _TRNRF_UPDATE_EN_RXADDR 0x01
#define _TRNRF_UPDATE_EN_AA 0x02
#define _TRNRF_UPDATE_SETUP_AW 0x04
#define _TRNRF_UPDATE_SETUP_RETR 0x08
#define _TRNRF_UPDATE_RF_CH 0x10
#define _TRNRF_UPDATE_RF_SETUP 0x20
#define _TRNRF_UPDATE_CRC 0x40
#define _TRNRF_UPDATE_DYNPD 0x80 // this and
#define _TRNRF_UPDATE_FEATURE 0x80 // this should be updated together anyway
#define _TRNRF_ACK 0
#define _TRNRF_NO_ACK 1
#define _TRNRF_MAX_RT_AUTOFLUSH 0x80
#define _TRNRF_MAX_RT_NO_FLUSH 0x00
#define _TRNRF_DYN_PAYLOAD 0xff
/* config struct */
typedef struct nrfConfig {
uint8_t channel; // 0-125, 2400MHz to 2525MHz
uint8_t rate_power; // data rate, tx power
uint8_t addr_width; // width of address, from 2-5 bytes
uint8_t payload_size[6]; // per-pipe RX payload length, from 1-32 bytes, 0=variable payload
uint8_t crc; // crc enable and crc mode bits
uint8_t pipe_ena; // rx pipe enable bits
uint8_t autoack_ena; // per-pipe autoack (enhanced shockburst) on/off
uint8_t retry; // global autoack retry config
uint8_t *tx_addr; // pointer to tx address, addr_width long
uint8_t tx_config; // state to go into after transmitting a packet, flush max_rt FIFO automatically?
uint8_t *rx_addr_p0; // pointer to rxp0 address, addr_width long
uint8_t *rx_addr_p1; // pointer to rxp1 address, addr_width long
uint8_t rx_pipe[4]; // rxp2-rxp5 last byte of address
} nrfConfig;
/* data handling */
void (*nRF24_rx_cb)(uint8_t pipe, uint8_t *pBuf, uint8_t len);
void (*nRF24_tx_done_cb)();
void (*nRF24_tx_max_rt_cb)();
/* function prototypes */
void nRF24_init(uint32_t cpu_freq);
uint8_t nRF24_interrupt();
uint8_t nRF24_reg_rw(uint8_t reg, uint8_t value);
uint8_t nRF24_reg_write(uint8_t cmd);
uint8_t nRF24_reg_read(uint8_t reg);
uint8_t nRF24_buf_write(uint8_t reg, void *pBuf, uint8_t bytes);
uint8_t nRF24_buf_read(uint8_t reg, void *pBuf, uint8_t bytes);
uint8_t nRF24_is_present(void);
void nRF24_set_txaddr(const uint8_t *addr);
void nRF24_set_rxaddr(uint8_t pipe, const uint8_t *addr);
void nRF24_set_channel(uint8_t chan);
void nRF24_set_rate(uint8_t rate);
void nRF24_set_power(uint8_t power);
void nRF24_set_addr_width(uint8_t width);
void nRF24_set_payload_size(uint8_t pipe, uint8_t size);
void nRF24_set_crc(uint8_t crc);
void nRF24_set_pipe(uint8_t pipe, uint8_t onoff);
void nRF24_set_autoack(uint8_t pipe, uint8_t onoff);
void nRF24_set_dynack(uint8_t onoff);
void nRF24_update_config(uint8_t mask);
void nRF24_set_tx_config(uint8_t max_rt_flush, uint8_t new_done_state);
void nRF24_mode_rx();
void nRF24_mode_tx();
void nRF24_mode_standby();
void nRF24_mode_off();
uint8_t nRF24_mode_get();
uint8_t nRF24_data_is_ready(void);
int8_t nRF24_packet_rx(uint8_t status, void *pBuf);
void nRF24_packet_tx(void *pBuf, uint8_t bytes, uint8_t noack);
uint8_t nRF24_rx_received_pipe();
void nRF24_clear_irq_flags(void);
#endif

View File

@ -0,0 +1,146 @@
/*
* true's NRF24L01 C library
* STM32L1xx interface driver
* basically: it's better than nothing
*
* $Id: true_nRF24L01_stm32l1xx.c 375 2015-07-06 02:52:40Z true $
*/
#include "true_nRF24l01_stm32l1xx.h"
/* hardware init */
void nRF24_spi_init(uint16_t speed) {
SPI_InitTypeDef spi;
spi.SPI_Mode = SPI_Mode_Master;
spi.SPI_BaudRatePrescaler = speed;
spi.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
spi.SPI_CPOL = SPI_CPOL_Low;
spi.SPI_CPHA = SPI_CPHA_1Edge;
spi.SPI_CRCPolynomial = 7;
spi.SPI_DataSize = SPI_DataSize_8b;
spi.SPI_FirstBit = SPI_FirstBit_MSB;
spi.SPI_NSS = SPI_NSS_Soft | SPI_NSSInternalSoft_Set;
SPI_Init(_TRNRF_SPI_PORT, &spi);
SPI_Cmd(_TRNRF_SPI_PORT, ENABLE);
}
void nRF24_interrupt_init()
{
EXTI_InitTypeDef exti;
NVIC_InitTypeDef nvic;
// make sure SYSCFG clock is running
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
// set up the IRQ pin to actually attach to an interrupt
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource11); // IRQ pin, also see lonelywolf_nRF24L01.h
exti.EXTI_Line = EXTI_Line11; // EXTI will be on line 11
exti.EXTI_LineCmd = ENABLE; // EXTI enabled
exti.EXTI_Mode = EXTI_Mode_Interrupt; // Generate IRQ
exti.EXTI_Trigger = EXTI_Trigger_Falling; // IRQ on signal falling
EXTI_Init(&exti);
// and then enable this interrupt at the lowest priority
nvic.NVIC_IRQChannel = EXTI15_10_IRQn;
nvic.NVIC_IRQChannelCmd = ENABLE;
nvic.NVIC_IRQChannelPreemptionPriority = 0x0F;
nvic.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_Init(&nvic);
}
/* driver init */
void nRF24_driver_init()
{
GPIO_InitTypeDef gpio;
#if _TRNRF_SPI_PORT_USE == 1
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); // SPI pins
#elif _TRNRF_SPI_PORT_USE == 2
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
RCC_AHBPeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
#endif
// set up other pin clocks
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE); // CE/IRQ pins
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE); // CS pin
// Configure SPI pins GPIO
gpio.GPIO_Speed = GPIO_Speed_10MHz;
gpio.GPIO_OType = GPIO_OType_PP;
gpio.GPIO_Mode = GPIO_Mode_AF;
gpio.GPIO_Pin = _TRNRF_SPI_SCK_PIN | _TRNRF_SPI_MISO_PIN | _TRNRF_SPI_MOSI_PIN;
GPIO_Init(_TRNRF_SPI_GPIO_PORT, &gpio);
// configure SPI pin AF
GPIO_PinAFConfig(_TRNRF_SPI_GPIO_PORT, _TRNRF_SPI_SCK_PINSRC, _TRNRF_SPI_GPIO_AF);
GPIO_PinAFConfig(_TRNRF_SPI_GPIO_PORT, _TRNRF_SPI_MISO_PINSRC, _TRNRF_SPI_GPIO_AF);
GPIO_PinAFConfig(_TRNRF_SPI_GPIO_PORT, _TRNRF_SPI_MOSI_PINSRC, _TRNRF_SPI_GPIO_AF);
// configure CS pin as output with push-pull
gpio.GPIO_Mode = GPIO_Mode_OUT;
gpio.GPIO_Pin = _TRNRF_SPI_CS_PIN;
GPIO_Init(_TRNRF_SPI_CS_PORT, &gpio);
// configure CE pin as output with push-pull
gpio.GPIO_Pin = _TRNRF_nRF24_CE_PIN;
GPIO_Init(_TRNRF_nRF24_CE_PORT, &gpio);
// configure IRQ pin as input with weak pull-Up
gpio.GPIO_Mode = GPIO_Mode_IN;
gpio.GPIO_PuPd = GPIO_PuPd_UP;
gpio.GPIO_Pin = _TRNRF_nRF24_IRQ_PIN;
GPIO_Init(_TRNRF_nRF24_IRQ_PORT, &gpio);
// set SPI and CE pins to startup values
_TRNRF_CSN_H();
_TRNRF_CE_L();
// start up SPI and IRQ interrupt
nRF24_spi_init(_TRNRF_SPI_BAUD);
nRF24_interrupt_init();
}
/**
* Communicates with the nRF24L01 (or anything else, really) over SPI.
*
* Since this command can be used for bulk transfer, it does NOT do anything
* with the SPI CS pin. Please check CS before and after using this function.
*
* @param data byte to send on SPI bus
*
* @return data returned on SPI bus
*/
uint8_t nRF24_spi_rw(uint8_t data) {
// Wait while DR register is not empty
while (SPI_I2S_GetFlagStatus(_TRNRF_SPI_PORT, SPI_I2S_FLAG_TXE) == RESET);
// Send byte to SPI
SPI_I2S_SendData(_TRNRF_SPI_PORT, data);
// Wait to receive byte
while (SPI_I2S_GetFlagStatus(_TRNRF_SPI_PORT, SPI_I2S_FLAG_RXNE) == RESET);
// Read byte from SPI bus
return SPI_I2S_ReceiveData(_TRNRF_SPI_PORT);
}
/* irq handler */
void EXTI15_10_IRQHandler(void) {
uint8_t status = 0;
if (EXTI_GetITStatus(EXTI_Line11) != RESET) {
status = nRF24_interrupt();
// do anything custom here if you like
EXTI_ClearITPendingBit(EXTI_Line11);
}
// fixes compiler warning for unused status
status = status | 0x00;
}

View File

@ -0,0 +1,91 @@
/*
* true's NRF24L01 C library
* STM32L1xx interface driver header
* basically: it's better than nothing
*
* $Id: true_nRF24L01_stm32l1xx.h 375 2015-07-06 02:52:40Z true $
*/
#ifndef __TRUE_NRF24L01_STM32L1XX_H
#define __TRUE_NRF24L01_STM32L1XX_H
// include stm libraries
#include "stm32l1xx_conf.h"
// and the nrf libraries
#include "true_nrf24l01.h"
/********************/
/**** SPI SELECT ****/
// which SPI to use?
#define _TRNRF_SPI_PORT_USE 1
#define _TRNRF_SPI_BAUD SPI_BaudRatePrescaler_4
// nRF24L01 CS (Chip Select) pin (SPI CS)
#define _TRNRF_SPI_CS_PORT GPIOD
#define _TRNRF_SPI_CS_PIN GPIO_Pin_2 // PD2
// nRF24L01 CE (Chip Enable) pin (handles RX/TX mode)
#define _TRNRF_nRF24_CE_PORT GPIOC
#define _TRNRF_nRF24_CE_PIN GPIO_Pin_10 // PC10
// nRF24L01 IRQ pin
#define _TRNRF_nRF24_IRQ_PORT GPIOC
#define _TRNRF_nRF24_IRQ_PIN GPIO_Pin_11 // PC11
/********************/
/**** SPI CONFIG ****/
#if _TRNRF_SPI_PORT_USE == 1
#define _TRNRF_SPI_PORT SPI1
#define _TRNRF_SPI_GPIO_AF GPIO_AF_SPI1
#define _TRNRF_SPI_GPIO_PORT GPIOB
#define _TRNRF_SPI_SCK_PIN GPIO_Pin_3
#define _TRNRF_SPI_MISO_PIN GPIO_Pin_4
#define _TRNRF_SPI_MOSI_PIN GPIO_Pin_5
#define _TRNRF_SPI_SCK_PINSRC GPIO_PinSource3
#define _TRNRF_SPI_MISO_PINSRC GPIO_PinSource4
#define _TRNRF_SPI_MOSI_PINSRC GPIO_PinSource5
#elif _TRNRF_SPI_PORT_USE == 2
#define _TRNRF_SPI_PORT SPI2
#define _TRNRF_SPI_GPIO_AF GPIO_AF_SPI2
#define _TRNRF_SPI_GPIO_PORT GPIOB
#define _TRNRF_SPI_SCK_PIN GPIO_Pin_13
#define _TRNRF_SPI_MISO_PIN GPIO_Pin_14
#define _TRNRF_SPI_MOSI_PIN GPIO_Pin_15
#define _TRNRF_SPI_SCK_PINSRC GPIO_PinSource13
#define _TRNRF_SPI_MISO_PINSRC GPIO_PinSource14
#define _TRNRF_SPI_MOSI_PINSRC GPIO_PinSource15
#endif
/********************/
/**** PIN MACROS ****/
// chip-enable (activates rx/tx modes)
#define _TRNRF_CE_L() GPIO_ResetBits(_TRNRF_nRF24_CE_PORT, _TRNRF_nRF24_CE_PIN)
#define _TRNRF_CE_H() GPIO_SetBits(_TRNRF_nRF24_CE_PORT, _TRNRF_nRF24_CE_PIN)
// SPI chipselect
#define _TRNRF_CSN_L() GPIO_ResetBits(_TRNRF_SPI_CS_PORT, _TRNRF_SPI_CS_PIN)
#define _TRNRF_CSN_H() GPIO_SetBits(_TRNRF_SPI_CS_PORT, _TRNRF_SPI_CS_PIN)
/********************/
/**** PROTOTYPES ****/
void nRF24_driver_init();
uint8_t nRF24_spi_rw(uint8_t data);
#endif

View File

@ -0,0 +1,20 @@
/**
* cgram.c: lcd cgram graphics constants
* 2014 by true
*
* ----
*
* $Id: cgram.c 327 2015-02-18 04:43:42Z true $
*
**/
#include <stdint.h>
const uint8_t cgram_crown[6][8] = {
{0x00, 0x00, 0x1C, 0x14, 0x1C, 0x0C, 0x0A, 0x09},
{0x0E, 0x0A, 0x0E, 0x04, 0x04, 0x0A, 0x11, 0x00},
{0x00, 0x00, 0x07, 0x05, 0x07, 0x06, 0x0A, 0x12},
{0x08, 0x08, 0x09, 0x0E, 0x08, 0x0F, 0x00, 0x00},
{0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x00},
{0x02, 0x02, 0x12, 0x0E, 0x02, 0x1E, 0x00, 0x00}
};

View File

@ -0,0 +1,20 @@
/**
* cgram.h: lcd cgram graphics constants
* 2014 by true
*
* ----
*
* $Id: cgram.h 327 2015-02-18 04:43:42Z true $
*
**/
#ifndef __PIRATE_DISPLAY_CGRAM_H
#define __PIRATE_DISPLAY_CGRAM_H
extern const uint8_t cgram_crown[6][8];
#endif

View File

@ -0,0 +1,103 @@
/**
* infopirate.c: namebadge and other information animated 8x2 display
* 2014 by true
*
* ----
*
* $Id: infopirate.c 327 2015-02-18 04:43:42Z true $
*
**/
#include <pirate.h>
#include "../device/lcd.h"
#include "../menu/lcd_menu.h" // for lcd_line
#include "infopirate.h"
#include "infopirate_prog.h"
#include "cgram/cgram.h"
uint8_t prog_idx; // currently selected program
uint8_t prog_loop; // current loop thru program
uint8_t (*infopirate_prog)(void);
uint8_t (*infopirate_prog_list[])() = {
&infopirate_prog_scroll_name_in_left,
&infopirate_prog_nameonly,
&infopirate_prog_scroll_name_out_left,
&infopirate_prog_logo01,
&infopirate_prog_logo02
};
const uint8_t prog_loop_run[] = { // amount of passes per program in static mode
1,
10,
1,
1,
1
};
/* functions */
void infopirate_init()
{
prog_wait = 0;
prog_loop = 0;
prog_idx = 0;
infopirate_prog = NULL;
}
static void infopirate_next_prog()
{
prog_wait = 0; // infopirate_prog.h
prog_loop = 0;
prog_idx++;
if (prog_idx >= sizeof_array(infopirate_prog_list)) prog_idx = 0;
infopirate_prog = infopirate_prog_list[prog_idx];
}
void infopirate_update()
{
uint8_t state;
state = INFOPIRATE_PROG_NONE;
if (infopirate_prog != NULL) {
state = infopirate_prog();
}
switch (state) {
case INFOPIRATE_PROG_NONE: {
prog_idx = 0;
prog_loop = 0;
infopirate_prog = infopirate_prog_list[0];
break;
}
case INFOPIRATE_PROG_DONE: {
prog_loop++;
if (prog_loop >= prog_loop_run[prog_idx]) {
infopirate_next_prog();
}
break;
}
}
}
void menu_infopirate_btn_prev()
{
}
void menu_infopirate_btn_next()
{
}
void menu_infopirate_btn_ok()
{
}

View File

@ -0,0 +1,33 @@
/**
* infopirate.h: namebadge and other information animated 8x2 display
* 2014 by true
*
* ----
*
* $Id: infopirate.h 327 2015-02-18 04:43:42Z true $
*
**/
#ifndef __PIRATE_DISPLAY_INFOPIRATE_H
#define __PIRATE_DISPLAY_INFOPIRATE_H
#define INFOPIRATE_PROG_NONE 0x00
#define INFOPIRATE_PROG_PAUSED 0x01
#define INFOPIRATE_PROG_RUNNING 0x02
#define INFOPIRATE_PROG_DONE 0xFE
/* prototypes */
void infopirate_init();
void infopirate_update();
void menu_infopirate_btn_prev();
void menu_infopirate_btn_next();
void menu_infopirate_btn_ok();
#endif

View File

@ -0,0 +1,158 @@
/**
* infopirate_prog.h: program functions for badge related bullshit
* 2014 by true
*
* ----
*
* $Id: infopirate_prog.h 327 2015-02-18 04:43:42Z true $
*
**/
#include "../menu/lcd_menu.h"
#include "cgram/cgram.h" // for CGRAM graphics tables
uint16_t prog_wait; // used by function to keep track of iteration time
uint32_t prog_state[4]; // used by the function to keep track of state
uint32_t prog_work[2]; // used for misc shit
/* functions */
uint8_t infopirate_prog_nameonly()
{
if (!prog_wait) {
prog_wait = 100;
lcd_set_height(LCD_CMD_DOUBLEHEIGHT);
}
strncpy(lcd_line[0], settings.name, 8);
prog_wait--;
return prog_wait ? INFOPIRATE_PROG_RUNNING : INFOPIRATE_PROG_DONE;
}
uint8_t infopirate_prog_scroll_name_in_left()
{
if (!prog_wait) {
prog_wait = 121;
prog_state[0] = 8;
lcd_set_height(LCD_CMD_DOUBLEHEIGHT);
} else if (prog_wait % 15 == 0) {
if (prog_state[0]) prog_state[0]--;
strncpy(lcd_line[0], " ", 8); // make the line all spaces
if (prog_state[0] < 8) {
lcd_line[0][prog_state[0]] = 0x00; // set our null
strncat(lcd_line[0], settings.name, 8); // copy our name
}
}
prog_wait--;
return prog_wait ? INFOPIRATE_PROG_RUNNING : INFOPIRATE_PROG_DONE;
}
uint8_t infopirate_prog_scroll_name_out_left()
{
int i, j;
if (!prog_wait) {
prog_wait = 121;
prog_state[0] = 0;
lcd_set_height(LCD_CMD_DOUBLEHEIGHT);
} else if (prog_wait % 15 == 0) {
if (prog_state[0] < 7) prog_state[0]++;
strncpy(lcd_line[0], " ", 8); // make the line all spaces
j = 0;
for (i = prog_state[0]; i < 8; i++) {
lcd_line[0][j++] = settings.name[i];
}
}
prog_wait--;
return prog_wait ? INFOPIRATE_PROG_RUNNING : INFOPIRATE_PROG_DONE;
}
uint8_t infopirate_prog_logo01()
{
int i;
static const char line1[8] = {0x00, 0x01, 0x02, 'T', 'h', 'r', 'e', 'e'};
static const char line2[8] = {0x03, 0x04, 0x05, 'K', 'i', 'n', 'g', 's'};
if (!prog_wait) {
// set our state timer
prog_wait = 400;
prog_state[0] = 0;
// enable CGRAM
lcd_set_height(LCD_CMD_SINGLEHEIGHT & 0xfe); // enable cgram
// set the CGRAM data to load
lcd_set_cgram_load(cgram_crown, sizeof_array(cgram_crown));
// set data
for (i = 0; i < 8; i++) {
lcd_line[0][i] = line1[i];
lcd_line[1][i] = line2[i];
}
}
prog_wait--;
return prog_wait ? INFOPIRATE_PROG_RUNNING : INFOPIRATE_PROG_DONE;
}
uint8_t infopirate_prog_logo02()
{
// prog_state[0] is the current character on this line to print
// prog_work[0] is the current character overall to print
// prog_work[1] is the current position of the character
if (!prog_wait) {
// new setup
prog_wait = 9;
prog_state[0] = 0; // first character
prog_work[0] = 0; // first character
prog_work[1] = 8; // scrolling from right, set to last character
// clear strings for new setup
strncpy(lcd_line[0], " ", 8);
strncpy(lcd_line[1], " ", 8);
} else if (prog_work[0] == 16) {
// we're done. wait a while
prog_wait = 210;
prog_work[0]++;
} else if (prog_wait == 1) {
// loop timeout expired, reload timer and process
prog_wait = 9;
static const char line1[] = "Whiskey ";
static const char line2[] = " Pirates";
lcd_set_height(LCD_CMD_SINGLEHEIGHT);
// did our character reach the end?
if (prog_work[1] <= prog_state[0]) {
// then go to the next character and reset right position
prog_work[0]++;
prog_state[0] = prog_work[0] & 0x07;
prog_work[1] = 8;
}
// do we have characters left to update?
if (prog_work[0] < 16) {
// working variables
char *src = prog_work[0] < 8 ? (char *)line1 : (char *)line2;
char *target = prog_work[0] < 8 ? lcd_line[0] : lcd_line[1];
// set the character one less than prog_work[1] to our target
target[prog_work[1] - 1] = src[prog_state[0]];
// if this isn't the last one, set the current working character to a space
if (prog_work[1] < 8) target[prog_work[1]] = 0x20;
// and continue scrolling our character in to the left
prog_work[1]--;
}
}
prog_wait--;
return (prog_wait != 10) ? INFOPIRATE_PROG_RUNNING : INFOPIRATE_PROG_DONE;
}

View File

@ -0,0 +1,135 @@
/**
* adc.h: manager for anything adc-related
* 2014 by true
*
* ----
*
* $Id: adc.c 327 2015-02-18 04:43:42Z true $
*
**/
#include <pirate.h>
#include "adc.h"
#include "gpio.h"
const tGPIO adc_gpio[] = {
{GPIOA, GPIO_Pin_5, 5}, // mic sig detect
{GPIOB, GPIO_Pin_0, 0}, // mic peak detect
{GPIOB, GPIO_Pin_0, 1}, // battery voltage
};
uint8_t adc_chan;
uint16_t adc_result[ADC_MAX_RESULT_COUNT];
/* functions */
void adc_init()
{
GPIO_InitTypeDef gpio;
ADC_CommonInitTypeDef adc_com;
ADC_InitTypeDef adc_init;
NVIC_InitTypeDef nvic;
int i;
// make sure the HSI is turned on - STM32L1xx uses HSI only for ADC
RCC_HSICmd(ENABLE);
// enable ADC clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
// set up pins as analog inputs
// NOTE: clocks were likely enabled earlier. fix if they weren't.
gpio.GPIO_Mode = GPIO_Mode_AN;
gpio.GPIO_Speed = GPIO_Speed_2MHz;
gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
for (i = 0; i < 3; i++) {
gpio.GPIO_Pin = adc_gpio[i].pin;
GPIO_Init(adc_gpio[i].port, &gpio);
}
// configure ADC initial values
ADC_CommonStructInit(&adc_com);
ADC_StructInit(&adc_init);
adc_init.ADC_ExternalTrigConv = 0;
// set up channels to read
ADC_RegularChannelConfig(ADC1, ADC_CHAN_MIC_SIG, ADC_READ_MIC_SIG + 1, ADC_SampleTime_4Cycles);
ADC_RegularChannelConfig(ADC1, ADC_CHAN_MIC_PEAK, ADC_READ_MIC_PEAK + 1, ADC_SampleTime_4Cycles);
ADC_RegularChannelConfig(ADC1, ADC_CHAN_BATT_VOLTAGE, ADC_READ_BATT_VOLTAGE + 1, ADC_SampleTime_4Cycles);
adc_init.ADC_ScanConvMode = ENABLE;
adc_init.ADC_NbrOfConversion = 3;
// enable end of conversion on each channel read
ADC_EOCOnEachRegularChannelCmd(ADC1, ENABLE);
// freeze ADC until data has been read
ADC_DelaySelectionConfig(ADC1, ADC_DelayLength_Freeze);
// initialize the ADC
ADC_CommonInit(&adc_com);
ADC_Init(ADC1, &adc_init);
// it doesn't look like STM32L100 has auto-calibrate feature,
// but if it did, we'd set it up here. baw.
// set up ADC power saving
ADC_PowerDownCmd(ADC1, ADC_PowerDown_Idle_Delay, ENABLE);
// enable interrupt
ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);
// set interrupt priority
nvic.NVIC_IRQChannel = ADC1_IRQn;
nvic.NVIC_IRQChannelPreemptionPriority = 3;
nvic.NVIC_IRQChannelSubPriority = 0;
nvic.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&nvic);
// finally, turn on the ADC
ADC_Cmd(ADC1, ENABLE);
}
void adc_deinit()
{
// reset ADC
ADC_DeInit(ADC1);
// and disable ADC clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, DISABLE);
}
void adc_start()
{
int adc_timeout = 200;
adc_chan = 0;
// verify ADC is powered up
while (ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS) == RESET) {
ADC_Cmd(ADC1, ENABLE);
if (--adc_timeout == 0) {
adc_result[2] |= 0xf000;
break;
}
}
// then start conversion if ADC is on
if (ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS) == SET) {
ADC_SoftwareStartConv(ADC1);
}
}
void ADC1_IRQHandler()
{
if (adc_chan < ADC_MAX_RESULT_COUNT) {
adc_result[adc_chan] = ADC_GetConversionValue(ADC1);
adc_chan++;
}
ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
}

View File

@ -0,0 +1,38 @@
/**
* adc.h: prototypes for adc functions
* 2014 by true
*
* ----
*
* $Id: adc.h 327 2015-02-18 04:43:42Z true $
*
**/
#ifndef __PIRATE_IF_ADC_H
#define __PIRATE_IF_ADC_H
#define ADC_MAX_RESULT_COUNT 3 // channels in use
#define ADC_READ_MIC_SIG 0
#define ADC_READ_MIC_PEAK 1
#define ADC_READ_BATT_VOLTAGE 2
#define ADC_CHAN_MIC_SIG ADC_Channel_5
#define ADC_CHAN_MIC_PEAK ADC_Channel_8
#define ADC_CHAN_BATT_VOLTAGE ADC_Channel_9
extern uint16_t adc_result[ADC_MAX_RESULT_COUNT];
void adc_init();
void adc_deinit();
void adc_channel(uint8_t rank);
void adc_start();
#endif

View File

@ -0,0 +1,8 @@
/**
* pirate gpio interface
* 2014 true
*
* ----
*
* $Id: gpio.c 327 2015-02-18 04:43:42Z true $
**/

View File

@ -0,0 +1,35 @@
/**
* gpio.h: pirate gpio interface
* 2014 true
*
* ----
*
* $Id: gpio.h 327 2015-02-18 04:43:42Z true $
*
**/
#ifndef __PIRATE_IF_GPIO_H
#define __PIRATE_IF_GPIO_H
#define BIT_0 1
#define BIT_1 (1 << 1)
#define BIT_2 (1 << 2)
#define BIT_3 (1 << 3)
#define BIT_4 (1 << 4)
#define BIT_5 (1 << 5)
#define BIT_6 (1 << 6)
#define BIT_7 (1 << 7)
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
typedef struct tGPIO {
GPIO_TypeDef *port;
uint16_t pin;
uint8_t pinsource;
} tGPIO;
#endif

View File

@ -0,0 +1,82 @@
/**
* i2c.h: pirate i2c interface, command and data buffering, and data receive callbacks
* 2014 true
*
* ----
*
* $Id: i2c.c 368 2015-06-16 06:49:48Z true $
*
**/
#include <pirate.h>
#include "i2c.h"
#include "gpio.h"
#define I2C_GPIO_SCL 0
#define I2C_GPIO_SDA 1
static const tGPIO i2c_pins[2][2] = {
{ // i2c1
{GPIOB, GPIO_Pin_8, 8}, // scl
{GPIOB, GPIO_Pin_9, 9} // sda
},
{ // i2c2
{GPIOB, GPIO_Pin_10, 10}, // scl
{GPIOB, GPIO_Pin_11, 11} // sda
}
};
/* functions */
void i2c_init(I2C_TypeDef *i2cdev, uint32_t speed)
{
GPIO_InitTypeDef gpio;
I2C_InitTypeDef i2c;
int i2c_idx;
if (i2cdev == I2C1) {
i2c_idx = 0;
} else {
i2c_idx = 1;
}
// enable peripheral clocks
// GPIOB is already enabled by LED driver
if (i2cdev == I2C1) {
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
} else if (i2cdev == I2C2) {
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2, ENABLE);
// and reset it (silicon bug?)
RCC_AHBPeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE);
RCC_AHBPeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE);
}
// set up peripheral
I2C_StructInit(&i2c);
i2c.I2C_ClockSpeed = speed;
I2C_Init(i2cdev, &i2c);
// set up pins
gpio.GPIO_Mode = GPIO_Mode_AF;
gpio.GPIO_OType = GPIO_OType_OD;
gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
gpio.GPIO_Speed = GPIO_Speed_2MHz;
gpio.GPIO_Pin = i2c_pins[i2c_idx][I2C_GPIO_SCL].pin | i2c_pins[i2c_idx][I2C_GPIO_SDA].pin;
GPIO_Init(i2c_pins[i2c_idx][I2C_GPIO_SCL].port, &gpio);
// set pin alternate function
GPIO_PinAFConfig(i2c_pins[i2c_idx][I2C_GPIO_SCL].port,
i2c_pins[i2c_idx][I2C_GPIO_SCL].pinsource, GPIO_AF_I2C1);
GPIO_PinAFConfig(i2c_pins[i2c_idx][I2C_GPIO_SDA].port,
i2c_pins[i2c_idx][I2C_GPIO_SDA].pinsource, GPIO_AF_I2C1);
// enable the i2c interrupts
// enable peripheral
I2C_Cmd(i2cdev, ENABLE);
}

View File

@ -0,0 +1,31 @@
/**
* i2c.h: pirate i2c interface, command and data buffering, and data receive callbacks
* 2014 true
*
* ----
*
* $Id: i2c.h 327 2015-02-18 04:43:42Z true $
*
**/
#ifndef __PIRATE_I2C_H
#define __PIRATE_I2C_H
// we're using this guy's library because it seems to work
#include "peter_i2c/peter_i2c.h"
#define I2C_BUF_SIZE 16 // power of 2
#define I2C_READ I2C_Direction_Receiver
#define I2C_WRITE I2C_Direction_Transmitter
/* prototypes */
void i2c_init(I2C_TypeDef *i2c, uint32_t speed);
#endif

View File

@ -0,0 +1,90 @@
/**
* led_pwm.c: led pwm configuration functions
* 2014 true
*
* ----
*
* $Id: led_pwm.c 327 2015-02-18 04:43:42Z true $
*
**/
#include <pirate.h>
#include "led_pwm.h"
/* functions */
void led_pwm_init(TIM_TypeDef *timer, uint16_t polarity, uint8_t channel_mask)
{
TIM_TimeBaseInitTypeDef tim_tb;
TIM_OCInitTypeDef tim_oc;
// set up with 250 levels of brightness
tim_tb.TIM_Prescaler = 5 - 1; // 6.4MHz
tim_tb.TIM_Period = 256 - 1; // 25KHz PWM, 5 updates/LED
tim_tb.TIM_ClockDivision = 0;
tim_tb.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(timer, &tim_tb);
// configure outputs as pwm
tim_oc.TIM_OCMode = TIM_OCMode_PWM1;
tim_oc.TIM_OutputState = TIM_OutputState_Enable;
tim_oc.TIM_Pulse = 0;
tim_oc.TIM_OCPolarity = polarity;
// configure pin for PWM output mode, enable preload
if (channel_mask & 0x01) {
TIM_OC1Init(timer, &tim_oc);
TIM_OC1PreloadConfig(timer, TIM_OCPreload_Enable);
}
if (channel_mask & 0x02) {
TIM_OC2Init(timer, &tim_oc);
TIM_OC2PreloadConfig(timer, TIM_OCPreload_Enable);
}
if (channel_mask & 0x04) {
TIM_OC3Init(timer, &tim_oc);
TIM_OC3PreloadConfig(timer, TIM_OCPreload_Enable);
}
if (channel_mask & 0x08) {
TIM_OC4Init(timer, &tim_oc);
TIM_OC4PreloadConfig(timer, TIM_OCPreload_Enable);
}
// finally, enable the timer
TIM_ARRPreloadConfig(timer, ENABLE);
TIM_Cmd(timer, ENABLE);
}
void led_pwm_init_all()
{
// enable peripheral clock and configure timers with PWM settings
// main led matrix
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
led_pwm_init(TIM2, TIM_OCPolarity_High,
LED_PWM_CH1 | LED_PWM_CH2 | LED_PWM_CH3 | LED_PWM_CH4);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
led_pwm_init(TIM3, TIM_OCPolarity_High,
LED_PWM_CH1 | LED_PWM_CH2 | LED_PWM_CH3 | LED_PWM_CH4);
// bone led matrix
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM11, ENABLE);
led_pwm_init(TIM11, TIM_OCPolarity_High, LED_PWM_CH1);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM9, ENABLE);
led_pwm_init(TIM9, TIM_OCPolarity_High, LED_PWM_CH1 | LED_PWM_CH2);
}
void led_pwm_set_oc(TIM_TypeDef *timer, uint32_t *oc)
{
timer->CCR1 = *oc++;
if (timer == TIM9) {
timer->CCR2 = *oc++;
} else if (timer == TIM2 || timer == TIM3 || timer == TIM4) {
timer->CCR2 = *oc++;
timer->CCR3 = *oc++;
timer->CCR4 = *oc;
}
}

View File

@ -0,0 +1,28 @@
/**
* led_pwm.h: led pwm configuration prototypes
* 2014 true
*
* ----
*
* $Id: led_pwm.h 327 2015-02-18 04:43:42Z true $
*
**/
#ifndef __PIRATE_LED_PWM_H
#define __PIRATE_LED_PWM_H
#define LED_PWM_CH1 0x01
#define LED_PWM_CH2 0x02
#define LED_PWM_CH3 0x04
#define LED_PWM_CH4 0x08
/* prototypes */
void led_pwm_init_all();
void led_pwm_set_oc(TIM_TypeDef *timer, uint32_t *oc);
#endif

View File

@ -0,0 +1,351 @@
#include "peter_i2c.h"
//-------------------------------------------
// Definition of local constants
//-------------------------------------------
#define I2C_TIMEOUT (0x1000)
//-------------------------------------------
// Declaration of local functions
//-------------------------------------------
static int I2C_check_dev(uint8_t addr);
static int I2C_start(I2C_TypeDef* I2Cx, uint8_t addr, uint8_t rdwr);
static int I2C_restart(I2C_TypeDef* I2Cx, uint8_t addr, uint8_t rdwr);
static int I2C_stop(I2C_TypeDef* I2Cx);
static int I2C_write(I2C_TypeDef* I2Cx, uint8_t data);
static int I2C_read(I2C_TypeDef* I2Cx, uint8_t ack);
// static int I2C_timeout(char *msg);
static int I2C_timeout(uint8_t flag);
/*
NVIC_InitStructure.NVIC_IRQChannel = PeterI2C_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
*/
//===============================================================================
// I2C_ReadTransfer - initiate a read transfer on the I2C bus
//
// Initiates a read transfer on the I2C bus.
// If a register address is specified (<addressLength> != 0) a write without a stop
// condition will be initiated to the device to write the address, before the
// read is initiated.
// If no address if required (sequential read) <addressLength> is set to 0.
//-------------------------------------------------------------------------------
// u08 dev_addr I2C device address
// u08 *buffer pointer to the buffer to store the read data.
// The buffer must be at least 'cnt' bytes long
// int cnt number of bytes to read
// u32 ptr register address, if required by the I2C-device
// u08 ptrlen length of the register address to be written.
// Valid values are 0..4
//-------------------------------------------------------------------------------
int I2C_ReadTransfer(uint8_t dev_addr, uint8_t *buffer, int cnt, uint32_t ptr, uint8_t ptrlen)
{
int i;
int rc = SUCCESS;
//-----------------------------------------------------------------------------
// parameter check
//-----------------------------------------------------------------------------
if ((buffer == 0) || (ptrlen > 4) || ((cnt | ptrlen) == 0))
{
return I2C_check_dev(dev_addr); // may be used to check if device is responding
}
//-----------------------------------------------------------------------------
// write the register address pointer to the device
//-----------------------------------------------------------------------------
if (ptrlen > 0)
{
rc = I2C_start(PeterI2C, dev_addr, I2C_Direction_Transmitter);
if (rc == SUCCESS)
{
for (i=1; i<=ptrlen; i++)
{
rc |= I2C_write(PeterI2C,((ptr >>(8*(ptrlen-i))) & 0xff));
}
}
}
//-----------------------------------------------------------------------------
// read data from device
//-----------------------------------------------------------------------------
if ((cnt > 0) && (rc == SUCCESS))
{
if (ptrlen > 0)
{
rc |= I2C_restart(PeterI2C, dev_addr, I2C_Direction_Receiver);
}
else
{
rc |= I2C_start(PeterI2C, dev_addr, I2C_Direction_Receiver);
}
if (rc == SUCCESS)
{
while (--cnt>0) // while more than one byte to read
{
*(buffer++) = I2C_read(PeterI2C, 1); // read next databyte from I2C device
}
*(buffer) = I2C_read(PeterI2C, 0); // read last databyte from I2C device
}
}
//-----------------------------------------------------------------------------
I2C_stop(PeterI2C); // stop the transmission
return rc;
}
//===============================================================================
// I2C_WriteTransfer r- initiate a write transfer on the I2C bus
//
// Initiates a write transfer on the I2C bus.
// If a register address is supplied it is inserted between the I2C device address
// and the data.
//-------------------------------------------------------------------------------
// u08 dev_addr I2C device address
// u08 *buffer pointer to the buffer to store the read data.
// The buffer must be at least 'cnt' bytes long
// int cnt number of bytes to read
// u32 ptr register address, if required by the I2C-device
// u08 ptrlen length of the register address to be written.
// Valid values are 0..4
//-------------------------------------------------------------------------------
int I2C_WriteTransfer(uint8_t dev_addr, uint8_t *buffer, int cnt, uint32_t ptr, uint8_t ptrlen)
{
int i;
int rc = SUCCESS;
//-----------------------------------------------------------------------------
// parameter check
//-----------------------------------------------------------------------------
if ((buffer == 0) || (ptrlen > 4) || ((cnt | ptrlen) == 0))
{
return I2C_check_dev(dev_addr); // may be used to check if device is responding
}
//-----------------------------------------------------------------------------
rc = I2C_start(PeterI2C, dev_addr, I2C_Direction_Transmitter);
if (rc == SUCCESS)
{
//---------------------------------------------------------------------------
// write the register address pointer to the device
//---------------------------------------------------------------------------
if (ptrlen > 0)
{
for (i=1; i<=ptrlen; i++)
{
rc |= I2C_write(PeterI2C,((ptr >>(8*(ptrlen-i))) & 0xff));
}
}
//---------------------------------------------------------------------------
// write data to the device
//---------------------------------------------------------------------------
for (i=0; i<cnt; i++)
{
rc |= I2C_write(PeterI2C,*(buffer++));
}
}
//-----------------------------------------------------------------------------
I2C_stop(PeterI2C); // stop the transmission
return rc;
}
//===============================================================================
// Check if a device is responding with acknowledge on the given I2C-Bus address
//-------------------------------------------------------------------------------
static int I2C_check_dev(uint8_t addr)
{
int timeout;
//-----------------------------------------------------------------------------
timeout = I2C_TIMEOUT;
while(I2C_GetFlagStatus(PeterI2C, I2C_FLAG_BUSY))
{
if((timeout--)==0) // wait until I2C-Bus is not busy anymore
{
return ERROR;
}
}
//-----------------------------------------------------------------------------
I2C_GenerateSTART(PeterI2C, ENABLE);
timeout = I2C_TIMEOUT;
while(!I2C_CheckEvent(PeterI2C, I2C_EVENT_MASTER_MODE_SELECT))
{
if((timeout--)==0) // wait while sending I2C-Bus START condition
{
I2C_GenerateSTOP(PeterI2C, ENABLE);
return ERROR;
}
}
//-----------------------------------------------------------------------------
I2C_Send7bitAddress(PeterI2C, addr, I2C_Direction_Transmitter);
timeout = I2C_TIMEOUT;
while(!I2C_CheckEvent(PeterI2C, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
{
if((timeout--)==0) // wait while sending slave address for write
{
I2C_GenerateSTOP(PeterI2C, ENABLE);
return ERROR;
}
}
//-----------------------------------------------------------------------------
I2C_GenerateSTOP(PeterI2C, ENABLE);
return SUCCESS;
}
//------------------------------------------------------------------
// This function issues a start condition and
// transmits the slave address + R/W bit
//
// Parameters:
// I2Cx --> the I2C peripheral e.g. I2C1
// addr --> the 7 bit slave address
// rdwr --> the tranmission direction can be:
// I2C_Direction_Tranmitter for Master transmitter mode
// I2C_Direction_Receiver for Master receiver
//------------------------------------------------------------------
static int I2C_start(I2C_TypeDef* I2Cx, uint8_t addr, uint8_t rdwr)
{
uint32_t timeout = (100 * I2C_TIMEOUT);
// wait until I2C1 is not busy anymore
while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_BUSY))
{
if((timeout--)==0) return I2C_timeout(I2C_TFLAG_BUS_BUSY);//I2C_timeout("I2C_start(): bus busy");
}
// Send I2C1 RESTART condition
return I2C_restart(I2Cx, addr, rdwr);
}
//------------------------------------------------------------------
// This function issues a restart condition and
// transmits the slave address + R/W bit
//
// Parameters:
// I2Cx --> the I2C peripheral e.g. I2C1
// addr --> the 7 bit slave address
// rdwr --> the tranmission direction can be:
// I2C_Direction_Tranmitter for Master transmitter mode
// I2C_Direction_Receiver for Master receiver
//------------------------------------------------------------------
static int I2C_restart(I2C_TypeDef* I2Cx, uint8_t addr, uint8_t rdwr)
{
uint32_t timeout = I2C_TIMEOUT;
// Send I2C1 START condition
I2C_GenerateSTART(I2Cx, ENABLE);
// wait for I2C1 EV5 --> Slave has acknowledged start condition
while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_MODE_SELECT))
{
if((timeout--)==0) return I2C_timeout(I2C_TFLAG_START_FAILED);//I2C_timeout("I2C_start(): start failed");
}
// Send slave Address for read or write
I2C_Send7bitAddress(I2Cx, addr << 1, rdwr);
//------------------------------------------------------------------------
// wait for I2C1 EV6, check if Slave has acknowledged Master transmitter
// or Master receiver mode, depending on the transmission direction
//------------------------------------------------------------------------
timeout = I2C_TIMEOUT;
if (rdwr==I2C_Direction_Transmitter)
{
while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
{
if((timeout--)==0) return I2C_timeout(I2C_TFLAG_NO_ACK);//I2C_timeout("I2C_start(): no acknowledge");
}
}
else if(rdwr==I2C_Direction_Receiver)
{
while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED))
{
if((timeout--)==0) return I2C_timeout(I2C_TFLAG_NO_ACK);//I2C_timeout("I2C_start(): no acknowledge");
}
}
return SUCCESS;
}
//------------------------------------------------------------------
// This function transmits one byte to the slave device
// Parameters:
// I2Cx --> the I2C peripheral e.g. I2C1
// data --> the data byte to be transmitted
//------------------------------------------------------------------
static int I2C_write(I2C_TypeDef* I2Cx, uint8_t data)
{
uint32_t timeout = I2C_TIMEOUT;
I2C_SendData(I2Cx, data);
// wait for I2C1 EV8_2 --> byte has been transmitted
while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_TRANSMITTED))
{
if((timeout--)==0) return I2C_timeout(I2C_TFLAG_WRITE_FAILED);//I2C_timeout("I2C_write(): write byte failed");
}
return SUCCESS;
}
//------------------------------------------------------------------
// This function reads one byte from the slave device
// and acknowledges the byte (requests another byte)
//------------------------------------------------------------------
static int I2C_read(I2C_TypeDef* I2Cx, uint8_t ack)
{
uint32_t timeout = I2C_TIMEOUT;
// enable acknowledge of recieved data
if (ack) {
I2C_AcknowledgeConfig(I2Cx, ENABLE);
} else {
I2C_AcknowledgeConfig(I2Cx, DISABLE);
}
// wait until one byte has been received
while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED))
{
if((timeout--)==0) return I2C_timeout(I2C_TFLAG_READ_FAILED);//I2C_timeout("I2C_read_ack(): read byte failed");
}
// read data from I2C data register and return data byte
return I2C_ReceiveData(I2Cx);
}
//------------------------------------------------------------------
// This funtion issues a stop condition and therefore
// releases the bus
//------------------------------------------------------------------
static int I2C_stop(I2C_TypeDef* I2Cx)
{
// Send I2C1 STOP Condition
I2C_GenerateSTOP(I2Cx, ENABLE);
return SUCCESS;
}
/*
static int I2C_timeout(char *msg)
{
// printf("TIMEOUT: %s\n",msg);
return ERROR;
}
*/
static int I2C_timeout(uint8_t flag)
{
if (flag < 32) {
// set some debug-related shit here, like maybe light an LED, etc.
// TODO: do this
}
return ERROR;
}
/*
void I2C1_EV_IRQHandler(void)
{
u32 event;
event = I2C_GetLastEvent(I2C2);
printf("I2C1_EV_IRQHandler(): Event=0x%08X\n",event);
//---------------------------------------------------
// todo, if I2C1 ISR mode shall be used
//---------------------------------------------------
}
void I2C2_EV_IRQHandler(void)
{
u32 event;
event = I2C_GetLastEvent(I2C2);
printf("I2C2_EV_IRQHandler(): Event=0x%08X\n",event);
//---------------------------------------------------
// todo, if I2C2 ISR mode shall be used
//---------------------------------------------------
}
*/

View File

@ -0,0 +1,72 @@
#ifndef _I2C_H
#define _I2C_H
#include <stdlib.h>
#include <stdint.h>
#include "stm32l1xx_conf.h"
//#define I2C1_OPEN
#define I2C2_OPEN
#define I2C_SCL_SPEED (200000) // SCL in Hz
#define I2C_OWN_ADDR (0x00) // use 0x00 for master
/**
* @brief Definition for I2C1
*/
#if defined I2C1_OPEN
#define PeterI2C I2C1
#define PeterI2C_CLK RCC_APB1Periph_I2C1
#define PeterI2C_SCL_PIN GPIO_Pin_6
#define PeterI2C_SCL_GPIO_PORT GPIOB
#define PeterI2C_SCL_GPIO_CLK RCC_AHB1Periph_GPIOB
#define PeterI2C_SCL_SOURCE GPIO_PinSource6
#define PeterI2C_SCL_AF GPIO_AF_I2C1
#define PeterI2C_SDA_PIN GPIO_Pin_9
#define PeterI2C_SDA_GPIO_PORT GPIOB
#define PeterI2C_SDA_GPIO_CLK RCC_AHB1Periph_GPIOB
#define PeterI2C_SDA_SOURCE GPIO_PinSource9
#define PeterI2C_SDA_AF GPIO_AF_I2C1
#define PeterI2C_IRQn I2C1_EV_IRQn
#define I2Cx_IRQHANDLER I2C1_EV_IRQHandler
#elif defined I2C2_OPEN
#define PeterI2C I2C2
#define PeterI2C_CLK RCC_APB1Periph_I2C2
#define PeterI2C_SCL_PIN GPIO_Pin_10
#define PeterI2C_SCL_GPIO_PORT GPIOB
#define PeterI2C_SCL_GPIO_CLK RCC_AHB1Periph_GPIOB
#define PeterI2C_SCL_SOURCE GPIO_PinSource10
#define PeterI2C_SCL_AF GPIO_AF_I2C2
#define PeterI2C_SDA_PIN GPIO_Pin_11
#define PeterI2C_SDA_GPIO_PORT GPIOB
#define PeterI2C_SDA_GPIO_CLK RCC_AHB1Periph_GPIOB
#define PeterI2C_SDA_SOURCE GPIO_PinSource11
#define PeterI2C_SDA_AF GPIO_AF_I2C2
#define PeterI2C_IRQn I2C2_EV_IRQn
#define I2Cx_IRQHANDLER I2C2_EV_IRQHandler
#else
#error "Please select the I2C-Device to be used (in i2c.h)"
#endif
#define I2C_TFLAG_BUS_BUSY 0x01
#define I2C_TFLAG_START_FAILED 0x02
#define I2C_TFLAG_NO_ACK 0x04
#define I2C_TFLAG_WRITE_FAILED 0x08
#define I2C_TFLAG_READ_FAILED 0x10
int I2C_ReadTransfer(uint8_t dev_addr, uint8_t *buffer, int cnt, uint32_t ptr, uint8_t ptrlen);
int I2C_WriteTransfer(uint8_t dev_addr, uint8_t *buffer, int cnt, uint32_t ptr, uint8_t ptrlen);
#endif /*_I2C_H*/

View File

@ -0,0 +1,236 @@
/**
* led_bone.c: skull crossbones led matrix handling functions
* 2014 true
*
* ----
*
* $Id: led_bone.c 373 2015-06-25 06:21:27Z true $
*
* ----
*
* Resources:
* - Uses TIM11 OC1 and TIM9 OC1 and OC2 for PWM output; for frequency, see led_pwm.c
*
* TODO:
* - use PWM for bone LEDs
* - integrate with main matrix patterns somehow
**/
#include <pirate.h>
#include "../interface/gpio.h"
#include "../interface/led_pwm.h"
#include "../device/lightsensor.h"
#include "led_matrix.h"
#include "led_bone.h"
// devices
static TIM_TypeDef *led_bone_row_pwm[3] = {TIM11, TIM9, TIM9};
static const tGPIO led_bone_row_gpio[3] = {
{GPIOA, GPIO_Pin_7, 7},
{GPIOB, GPIO_Pin_13, 13},
{GPIOB, GPIO_Pin_14, 14}
};
static const tGPIO led_bone_col_gpio[3] = {
{GPIOB, GPIO_Pin_12, 12},
{GPIOB, GPIO_Pin_15, 15},
{GPIOA, GPIO_Pin_8, 8}
};
const uint8_t led_bone_order[8] = {
BONE_LED_TR_UPPER,
BONE_LED_TR_LOWER,
BONE_LED_BR_UPPER,
BONE_LED_BR_LOWER,
BONE_LED_BL_LOWER,
BONE_LED_BL_UPPER,
BONE_LED_TL_LOWER,
BONE_LED_TL_UPPER
};
// pwm level
static uint8_t led_bone_mode;
static uint8_t led_level[9];
// led programs
#include "led_bone_prog.h"
static void (*led_program)();
static void (*led_program_list[])() = {
led_prog_all_on,
led_prog_loops,
led_prog_updown
};
const char led_bone_prog_name[LED_BONE_PROG_COUNT][16] = {
{"AllOn"},
{"Loops"},
{"UpDown"},
};
// currently lit led
static uint8_t led_index = 0;
/* functions */
void led_bone_io_init()
{
uint8_t i;
GPIO_InitTypeDef gpio;
// configure LOW as standard outputs
gpio.GPIO_Mode = GPIO_Mode_OUT;
gpio.GPIO_OType = GPIO_OType_PP;
gpio.GPIO_Speed = GPIO_Speed_2MHz;
// init and set low
for (i = 0; i < 3; i++) {
gpio.GPIO_Pin = led_bone_col_gpio[i].pin;
GPIO_Init(led_bone_col_gpio[i].port, &gpio);
GPIO_ResetBits(led_bone_col_gpio[i].port, led_bone_col_gpio[i].pin);
}
// configure HIGH pins as AF
gpio.GPIO_Mode = GPIO_Mode_AF;
for (i = 0; i < 3; i++) {
gpio.GPIO_Pin = led_bone_row_gpio[i].pin;
GPIO_Init(led_bone_row_gpio[i].port, &gpio);
}
// configure AF on these pins
GPIO_PinAFConfig(led_bone_row_gpio[0].port, led_bone_row_gpio[0].pinsource, GPIO_AF_TIM11);
GPIO_PinAFConfig(led_bone_row_gpio[1].port, led_bone_row_gpio[1].pinsource, GPIO_AF_TIM9);
GPIO_PinAFConfig(led_bone_row_gpio[2].port, led_bone_row_gpio[2].pinsource, GPIO_AF_TIM9);
}
void led_bone_io_disable()
{
GPIO_InitTypeDef gpio;
int i;
gpio.GPIO_Mode = GPIO_Mode_OUT;
gpio.GPIO_OType = GPIO_OType_OD;
gpio.GPIO_PuPd = GPIO_PuPd_UP;
for (i = 0; i < 3; i++) {
gpio.GPIO_Pin = led_bone_row_gpio[i].pin;
GPIO_Init(led_bone_row_gpio[i].port, &gpio);
}
}
void inline led_bone_next()
{
uint8_t update_col;
uint8_t update_row;
uint16_t update_scaler;
uint32_t update_level[3] = {
0, 0, 0
};
// set active column
update_col = led_index % 3;
// set updated row
if (led_index < 3) {
update_row = 0;
} else if (led_index < 6) {
update_row = 1;
} else {
update_row = 2;
}
// set new levels
// update_level[update_row] = *(led_level + led_index);
update_scaler = (settings.led_autoadjust & 0x80) ? lightsensor_get_scalerval(LIGHTSENS_SCALED_BONES) : 256;
update_level[update_row] = (led_level[led_index] * update_scaler) >> 8;
// disable PWM
TIM_Cmd(led_bone_row_pwm[0], DISABLE);
TIM_Cmd(led_bone_row_pwm[1], DISABLE);
// clear all columns (set high)
GPIO_SetBits(led_bone_col_gpio[0].port, led_bone_col_gpio[0].pin);
GPIO_SetBits(led_bone_col_gpio[1].port, led_bone_col_gpio[1].pin);
GPIO_SetBits(led_bone_col_gpio[2].port, led_bone_col_gpio[2].pin);
// set new row pwm value
led_pwm_set_oc(led_bone_row_pwm[0], &update_level[0]); // TIM11 has pin0
led_pwm_set_oc(led_bone_row_pwm[1], &update_level[1]); // TIM9 has pin1, pin2
// reset pwm counter (fixes matrix glitches)
TIM_SetCounter(led_bone_row_pwm[0], 0xff);
TIM_SetCounter(led_bone_row_pwm[1], 0xff);
// generate update event to apply pwm values
TIM_GenerateEvent(led_bone_row_pwm[0], TIM_EventSource_Update);
TIM_GenerateEvent(led_bone_row_pwm[1], TIM_EventSource_Update);
// and now set the active column (set low)
GPIO_ResetBits(led_bone_col_gpio[update_col].port, led_bone_col_gpio[update_col].pin);
// re-enable PWM
TIM_Cmd(led_bone_row_pwm[0], ENABLE);
TIM_Cmd(led_bone_row_pwm[1], ENABLE);
// next led
led_index++;
if (led_index >= 9) {
led_index = 0;
}
}
void led_bone_set_mode(uint8_t mode)
{
led_bone_mode = mode;
}
void led_bone_set_program(uint8_t program_idx, uint8_t init,
uint16_t wait, uint16_t level, uint32_t offset, uint32_t settings)
{
// we need to be in program mode
led_bone_set_mode(LED_MATRIX_MODE_PROGRAM);
// update the program pointer
led_program = led_program_list[program_idx];
// set initial program variables
led_prog_set_wait = wait;
led_prog_set_level = level;
led_prog_set_offset = offset;
led_prog_set_option = settings;
// is this a new set? if so, initialize program parameters
if (init) {
uint8_t i;
led_prog_wait = 0;
for (i = 0; i < 4; i++) {
led_prog_state[i] = 0;
led_prog_work[i] = 0;
}
}
}
void led_bone_mode_update()
{
uint8_t i;
switch (led_bone_mode) {
case LED_MATRIX_MODE_PROGRAM: {
// if we have a valid program loaded, run it
if (led_program != NULL) {
led_program();
}
break;
}
case LED_MATRIX_MODE_OFF: {
led_program = NULL;
for (i = 0; i < 9; i++) {
led_level[i] = 0;
}
break;
}
}
}

View File

@ -0,0 +1,54 @@
/**
* led_bone.h: skull crossbones led matrix handling prototypes
* 2014 true
*
* ----
*
* $Id: led_bone.h 364 2015-06-12 04:44:55Z true $
*
**/
#ifndef __PIRATE_LED_BONE_H
#define __PIRATE_LED_BONE_H
/* struct */
typedef struct LEDBonePattern {
uint16_t wait;
uint8_t led[9];
} LEDBonePattern;
/* constants */
#define LED_BONE_PROG_COUNT 3
#define LED_BONE_PTRN_COUNT 0
/* led positions */
#define BONE_LED_BR_LOWER 0
#define BONE_LED_TR_LOWER 1
#define BONE_LED_BR_UPPER 3
#define BONE_LED_TL_UPPER 4
#define BONE_LED_TL_LOWER 5
#define BONE_LED_TR_UPPER 6
#define BONE_LED_BL_UPPER 7
#define BONE_LED_BL_LOWER 8
/* variables */
extern const char led_bone_prog_name[LED_BONE_PROG_COUNT][16];
/* prototypes */
void led_bone_io_init();
void led_bone_io_disable();
void led_bone_next();
void led_bone_mode_update();
void led_bone_set_mode(uint8_t mode); // used for turning off
void led_bone_set_program(uint8_t program_idx, uint8_t init,
uint16_t wait, uint16_t level, uint32_t offset, uint32_t settings);
#endif

View File

@ -0,0 +1,43 @@
/**
* led_bone.c: skull crossbones led matrix fixed patterns
* 2014 true
*
* ----
*
* $Id: led_bone_pattern.h 327 2015-02-18 04:43:42Z true $
*
**/
// LEDs are in this arrangement:
// W-BR W-TR xxxx
// P-BR P-TL W-TL
// P-TR P-BL W-BL
// all on 100%
static const LEDBonePattern led_pattern_01[] = {
{1000, {0xff, 0xff, 0x00,
0xff, 0xff, 0xff,
0xff, 0xff, 0xff}},
};
// all on 50%
static const LEDBonePattern led_pattern_02[] = {
{1000, {0x33, 0x33, 0x00,
0x33, 0x33, 0x33,
0x33, 0x33, 0x33}},
};
// all on, white matching apparent purple 100% brightness
static const LEDBonePattern led_pattern_03[] = {
{1000, {0x10, 0x10, 0x00,
0x10, 0x10, 0x10,
0x10, 0x10, 0x10}},
};
// pattern count - make sure this is updated with the amount
// of entries in the patterns above!
static uint8_t led_pattern_size[] = {
1,
1,
1
};

View File

@ -0,0 +1,143 @@
/**
* led_bone.c: skull crossbones led matrix fixed patterns
* 2014 true
*
* ----
*
* $Id: led_bone_prog.h 364 2015-06-12 04:44:55Z true $
*
**/
static uint16_t led_prog_wait; // used by function to keep track of iteration time
static uint32_t led_prog_state[4]; // used by the function to keep track of lit LEDs, state
static uint32_t led_prog_work[4]; // used for misc shit
static uint16_t led_prog_set_wait; // used by setter function to set iteration time in ms
static uint16_t led_prog_set_level; // used by setter function to set desired level
static uint32_t led_prog_set_offset; // used by setter function to set desired offset
static uint32_t led_prog_set_option; // used by setter to set options
/* programs */
static void led_prog_all_on()
{
uint8_t i;
if (!led_prog_wait) {
led_prog_wait = 50;
for (i = 0; i < 9; i++) {
led_level[i] = led_prog_set_level & 0xff;
}
}
led_prog_wait--;
}
/********
* around the bones in a loop program
* speed: set as desired
* options: bit 2 = direction (0 = clockwise, 1 = counter-clockwise),
* bit 4 = decay trails faster, bit 5 = decay trails even faster,
* bit 6 = trails enable
*********/
static void led_prog_loops()
{
uint8_t i;
if (!led_prog_wait) {
// load new timer wait value
led_prog_wait = led_prog_set_wait * 5;
// first run?
if (!led_prog_state[3]) {
// store starting offset
led_prog_state[0] = led_prog_set_offset & 0x07;
// reset levels
for (i = 0; i < 9; i++) {
led_level[i] = 0;
}
led_prog_state[3] = 1;
}
// set decay rate (LED PWM active values are right shifted by this value)
led_prog_work[0] = 1;
if (led_prog_set_option & BIT_4) led_prog_work[0]++;
if (led_prog_set_option & BIT_5) led_prog_work[0] += 2;
for (i = 0; i < 8; i++) {
if (i == led_prog_state[0]) {
// LED is next in line so turn it on
led_level[led_bone_order[i]] = led_prog_set_level & 0xff;
} else {
// LED is not on so decay or turn off
led_level[led_bone_order[i]] = (led_prog_set_option & BIT_6) ?
led_level[led_bone_order[i]] >> led_prog_work[0] : 0;
}
}
// update state with next LED
led_prog_state[0] += (led_prog_set_option & BIT_2) ? 7 : 1;
led_prog_state[0] &= 0x07;
}
led_prog_wait--;
}
/********
* sweeping up and down symetically
* speed: set as desired
* options: bit 4 = decay trails faster, bit 5 = decay trails even faster,
* bit 6 = trails enable
*********/
void led_prog_updown()
{
uint8_t i;
if (!led_prog_wait) {
// load new timer wait value
led_prog_wait = led_prog_set_wait * 5;
// first run?
if (!led_prog_state[3]) {
// store starting offset
led_prog_state[0] = led_prog_set_offset & 0x07;
// reset levels
for (i = 0; i < 9; i++) {
led_level[i] = 0;
}
led_prog_state[3] = 1;
}
// set decay rate (LED PWM active values are right shifted by this value)
led_prog_work[0] = 1;
if (led_prog_set_option & BIT_4) led_prog_work[0] = 2;
if (led_prog_set_option & BIT_5) led_prog_work[0] += 2;
led_prog_work[1] = led_prog_state[0] >= 4 ? 7 - led_prog_state[0] : led_prog_state[0];
for (i = 0; i < 4; i++) {
if (i == led_prog_work[1]) {
// LED is next in line so turn it on
led_level[led_bone_order[i]] = led_prog_set_level & 0xff;
} else {
// LED is not on so decay or turn off
led_level[led_bone_order[i]] = (led_prog_set_option & BIT_6) ?
led_level[led_bone_order[i]] >> led_prog_work[0] : 0;
}
led_level[led_bone_order[7 - i]] = led_level[led_bone_order[i]];
}
// update state with next LED
led_prog_state[0] += (led_prog_set_option & BIT_2) ? 7 : 1;
led_prog_state[0] &= 0x07;
}
led_prog_wait--;
}

View File

@ -0,0 +1,295 @@
/*
* led_eyes_prog.h: programs for the RGBLED eyes
* 2014 by true
*
* ----
*
* $Id: led_eyes_prog.h 375 2015-07-06 02:52:40Z true $
*
**/
uint16_t led_prog_wait; // used by function to keep track of iteration time
uint32_t led_prog_state[4]; // used by the function to keep track of lit LEDs, state
uint32_t led_prog_work[4]; // used for misc shit
uint16_t led_prog_set_wait; // used by setter function to set iteration time in ms
uint16_t led_prog_set_level; // used by setter function to set desired level
uint32_t led_prog_set_offset; // used by setter function to set desired offset
uint32_t led_prog_set_option; // used by setter to set options
/* programs */
/********
* candle flicker
* option sets the color mix; each 8 bits set the mix level in RGBx
* (so 0xff0000?? would be red, etc)
* xx option bits determine if independent (1 = yes, 0 = no)
*********/
static void led_prog_candle_flicker()
{
static const uint8_t lookup[] = {20, 52, 84, 116, 148, 184, 220, 255};
uint32_t rand = 0;
uint8_t new_val[3];
int i;
// ideally we want to update flicker at about 454.54hz (as close to 440hz as we can get) = 11
// I don't know where I read this so let's just update LEDs less often because it looks nicer
if (!led_prog_wait) {
led_prog_wait = 45;
// set which LED to update if in alternating mode
led_prog_state[0] = led_prog_state[0] ? 0 : 1;
rand = pirate_prng() & 0x1f;
rand = (rand > 7) ? lookup[7] : lookup[rand];
// create scaled value
new_val[0] = ((led_prog_set_option >> 24));
new_val[1] = ((led_prog_set_option >> 16) & 0xff);
new_val[2] = ((led_prog_set_option >> 8) & 0xff);
for (i = 0; i < 3; i++) {
new_val[i] = (rand * new_val[i]) >> 8;
}
// update LED values
if (led_prog_set_option & 1) {
led_level[led_prog_state[0]][0] = new_val[0];
led_level[led_prog_state[0]][1] = new_val[1];
led_level[led_prog_state[0]][2] = new_val[2];
} else {
led_level[0][0] = led_level[1][0] = new_val[0];
led_level[0][1] = led_level[1][1] = new_val[1];
led_level[0][2] = led_level[1][2] = new_val[2];
}
}
led_prog_wait--;
}
static void led_prog_candle_flicker_favcolor()
{
led_prog_set_option = settings.fav_color[0] << 24 | settings.fav_color[1] << 16 |
settings.fav_color[2] << 8 | (led_prog_set_option & 0x01);
led_prog_candle_flicker();
}
/********
* static led or random led flasher
* option sets the color mix; each 8 bits set the mix level in RGBx
* (so 0xff0000?? would be red, etc)
* low bit of option sets LEDs in independent mode (1 = yes, 0 = no)
* offset sets the flash color mix
* low 8 bits of offset set the threshold of the flasher (0x00=always, 0xff=never)
* having eyes on while set to always activate will simply alternate the LEDs
*********/
static void led_prog_randflasher()
{
int i;
if (!led_prog_wait) {
led_prog_wait = led_prog_set_wait * 5;
// set which LED to operate
led_prog_state[0] = led_prog_state[0] ? 0 : 1;
// set background levels on all LEDs
for (i = 0; i < 2; i++) {
led_level[i][0] = ((led_prog_set_option >> 24));
led_level[i][1] = ((led_prog_set_option >> 16) & 0xff);
led_level[i][2] = ((led_prog_set_option >> 8) & 0xff);
}
// set flash
if (pirate_prng() > (led_prog_set_offset & 0xff)) {
if (!(led_prog_set_option & BIT_0) || (led_prog_state[0] == 0)) {
led_level[0][0] = ((led_prog_set_offset >> 24));
led_level[0][1] = ((led_prog_set_offset >> 16) & 0xff);
led_level[0][2] = ((led_prog_set_offset >> 8) & 0xff);
}
if (!(led_prog_set_option & BIT_0) || (led_prog_state[0] == 1)) {
led_level[1][0] = ((led_prog_set_offset >> 24));
led_level[1][1] = ((led_prog_set_offset >> 16) & 0xff);
led_level[1][2] = ((led_prog_set_offset >> 8) & 0xff);
}
}
}
led_prog_wait--;
}
/********
* mic spl meter
* level: sets the threshold scaler. 0xff = 100 is max, 0x80 = 50 is max, and so on
* offset: sets the cold (0%) color, see above for format
* option: sets the hot (100%) color, see above for format
* last 7 bits of option sets how fast the ramping up is
* last 7 bits of offset sets how fast the ramping down is
*********/
static void led_prog_mic_spl()
{
int i;
if (!led_prog_wait) {
led_prog_wait = led_prog_set_wait * 5;
// first run?
if (led_prog_set_option & 0x80) {
led_prog_work[0] = 0;
led_prog_set_option |= 0x80;
}
// speed is set?
if (!(led_prog_set_option & 0x7f)) {
led_prog_set_option |= 0x0f;
}
if (!(led_prog_set_offset & 0x7f)) {
led_prog_set_offset |= 0x01;
}
// set our value
if (mic_peak > led_prog_work[0]) {
led_prog_work[0] += led_prog_set_option & 0xff;
if (led_prog_work[0] > mic_peak) led_prog_work[0] = mic_peak;
} else {
led_prog_work[0] -= led_prog_set_offset & 0xff;
if (led_prog_work[0] < mic_peak) led_prog_work[0] = mic_peak;
}
// make it a percentage
led_prog_work[1] = pirate_scale(led_prog_work[0], settings.mic_cal[0], settings.mic_cal[1], 0, 255);
// scale value
led_prog_state[0] = pirate_scale(led_prog_work[1], (led_prog_set_level >> 8), (led_prog_set_level & 0xff), 0, 248);
// scale hot/cold levels on LEDs
for (i = 0; i < 3; i++) {
led_level[0][i] = led_level[1][i] = pirate_scale(led_prog_state[0], 0, 248,
((led_prog_set_offset >> ((3 - i) << 3)) & 0xff),
((led_prog_set_option >> ((3 - i) << 3)) & 0xff));
}
}
led_prog_wait--;
}
/********
* color fader, rgb
* starts out blank right now
* level does nothing right now
* option sets the order and mix, for each half byte (0x01=red, 0x02=blue, 0x04=grn, 0x08=rampdown)
* (order is LS to MS) -
* 0x8 = stop pattern (go to beginning)
* 0x9-0xF = 0x1-0x7 except other colors must finish dimming
* offset sets the lag in the right eye, but this doesn't work right now, so just inverts
*
*********/
static void led_prog_fader()
{
uint32_t bitshift;
uint32_t bitfield;
uint8_t nextstep;
int i;
if (!led_prog_wait) {
led_prog_wait = led_prog_set_wait * 5;
// first run?
if (!led_prog_state[3]) {
led_prog_work[0] = 0;
led_prog_work[1] = 0;
led_prog_work[2] = 0;
led_prog_state[0] = 0;
led_prog_state[1] = led_prog_set_offset;
led_prog_state[3] = 1;
}
// figure out what colors to manipulate for the left eye
bitshift = (led_prog_state[0] << 2);
bitfield = (led_prog_set_option >> bitshift) & 0xF;
// is this a reset instruction?
if (bitfield == 0x8) {
// start over
led_prog_state[0] = 0;
bitfield = led_prog_set_option & 0xF;
}
// is this a require-clearing instruction?
if (bitfield & 0x8) {
//copy inverse of low nybble to high nybble
bitfield |= (~(bitfield & 0xf)) << 4;
// clear high bits in each nybble if set
bitfield &= 0x77;
}
nextstep = 0;
// and manipulate (fade) them
if (bitfield) {
if (bitfield >> 4) { // fade-down bit set
for (i = 0; i <= 2; i++) {
if ((bitfield >> 4) & (1 << i)) { // config bit unset (set here)
if (led_prog_work[i]) {
led_prog_work[i]--; // means fade down for unused channels
} else {
nextstep |= (1 << (i + 4)); // and signal when we are done with this channel
}
}
}
}
for (i = 0; i <= 2; i++) {
if (bitfield & (1 << i)) { // low bit set, normal fade-up addition
if (led_prog_work[i] < 255) {
led_prog_work[i]++;
} else {
nextstep |= (1 << i); // all the way up? signal we're done
}
} else if (!(bitfield & 0x8) && led_prog_work[i]) {
led_prog_work[i]--; // neither high nor low set? fade down
}
}
}
// figure out delay for right eye
if (led_prog_state[1]) {
led_prog_state[1]--;
} else {
// ok, delay is done, we can start manipulating the right eye
}
// special task for forcing all outputs to 0
if (!bitfield) {
// if unset, then we need to dim down to nothing
for (i = 0; i <= 2; i++) {
if (led_prog_work[i] & 0xff) {
led_prog_work[i]--;
} else {
nextstep++;
}
}
if (nextstep == 3) {
led_prog_state[0]++;
led_prog_state[0] %= 8;
}
} else if (nextstep == bitfield) {
// all of our LEDs are set to level, we can proceed to the next step
led_prog_state[0]++;
led_prog_state[0] %= 8;
}
// actually set LEDs
for (i = 0; i <= 2; i++) {
led_level[0][i] = led_prog_work[i] & 0xff;
//led_level[1][i] = (led_prog_work[i] >> 8) & 0xff;
led_level[1][i] = led_prog_set_offset ? ~led_prog_work[i] : led_prog_work[i];
}
}
led_prog_wait--;
}

View File

@ -0,0 +1,238 @@
/*
* led_matrix.c: main skull led matrix handling functions
* 3414 true
*
* ----
*
* $Id: led_matrix.c 373 2015-06-25 06:21:27Z true $
*
* ----
*
* Resources:
* - Uses TIM2 and TIM3 as PWM output; for frequency, see led_pwm.c
**/
#include <pirate.h>
#include "../interface/gpio.h"
#include "../interface/led_pwm.h"
#include "../device/lightsensor.h"
#include "led_matrix.h"
// pwm devices
TIM_TypeDef *led_pwm[2] = {TIM2, TIM3};
// pwm pins
// order is 0=white, 1=purple. row=high, col=low
GPIO_TypeDef *led_row_port[2] = {GPIOA, GPIOC};
uint16_t led_row_pin_mask[2] = {0x000f, 0x03c0};
const uint8_t led_row_pin_low[2] = {0, 6};
GPIO_TypeDef *led_col_port[2] = {GPIOC, GPIOC};
uint16_t led_col_pin_mask[2] = {0xf000, 0x003c};
const uint8_t led_col_pin_low[2] = {12, 2};
// led mode
uint8_t led_matrix_mode;
// led brightness
uint8_t led_level[2][16];
// led programs
#include "led_matrix_prog.h"
static void (*led_program)();
static void (*led_program_list[])() = {
led_prog_debug,
led_prog_loops,
led_prog_loops_mic,
led_prog_loops_rotate,
led_prog_rand_on_rand_off,
led_prog_mic_spl_meter
};
const char led_matrix_prog_name[LED_MATRIX_PROG_COUNT][16] = {
{"Debug"},
{"Loops"},
{"Loops+Mic"},
{"Loops+Rotate"},
{"Random"},
{"SPLMeter"},
};
// currently lit LED
static uint8_t led_index;
/* functions */
void led_matrix_io_init()
{
int i;
GPIO_InitTypeDef gpio;
// configure LOW as standard outputs
gpio.GPIO_Mode = GPIO_Mode_OUT;
gpio.GPIO_OType = GPIO_OType_PP;
gpio.GPIO_Speed = GPIO_Speed_10MHz;
gpio.GPIO_Pin = led_col_pin_mask[0];
GPIO_Init(led_col_port[0], &gpio);
gpio.GPIO_Pin = led_col_pin_mask[1];
GPIO_Init(led_col_port[1], &gpio);
// and set low
GPIO_ResetBits(led_col_port[0], led_col_pin_mask[0]);
GPIO_ResetBits(led_col_port[1], led_col_pin_mask[1]);
// configure HIGH pins as AF
gpio.GPIO_Mode = GPIO_Mode_AF;
gpio.GPIO_Pin = led_row_pin_mask[0];
GPIO_Init(led_row_port[0], &gpio);
gpio.GPIO_Pin = led_row_pin_mask[1];
GPIO_Init(led_row_port[1], &gpio);
// set AF on HIGH pins
for (i = 0; i < 4; i++) {
GPIO_PinAFConfig(led_row_port[0], led_row_pin_low[0] + i, GPIO_AF_TIM2);
GPIO_PinAFConfig(led_row_port[1], led_row_pin_low[1] + i, GPIO_AF_TIM3);
}
// MAKE SURE to enable PWM for these to work!
}
void led_matrix_io_disable()
{
GPIO_InitTypeDef gpio;
int i;
gpio.GPIO_Mode = GPIO_Mode_OUT;
gpio.GPIO_OType = GPIO_OType_OD;
gpio.GPIO_PuPd = GPIO_PuPd_UP;
for (i = 0; i < 4; i++) {
gpio.GPIO_Pin = led_row_pin_low[0] + i;
GPIO_Init(led_row_port[0], &gpio);
gpio.GPIO_Pin = led_row_pin_low[1] + i;
GPIO_Init(led_row_port[1], &gpio);
}
}
void inline led_matrix_next()
{
uint32_t update_col;
uint32_t update_row;
uint16_t update_scaler;
uint32_t update_level[2][4] = {
//{0xff, 0xff, 0xff, 0xff},
//{0xff, 0xff, 0xff, 0xff}
{0x100, 0x100, 0x100, 0x100},
{0x100, 0x100, 0x100, 0x100}
};
// set next index
led_index++;
led_index &= 0x0f;
// set active column
update_col = led_index % 4;
update_row = led_index >> 2;
// set new levels
update_scaler = (settings.led_autoadjust & 0x80) ? lightsensor_get_scalerval(LIGHTSENS_SCALED_SKULL_WHT) : 256;
update_level[0][update_row] = 0x100 - ((led_level[0][led_index] * update_scaler) >> 8);
update_scaler = (settings.led_autoadjust & 0x80) ? lightsensor_get_scalerval(LIGHTSENS_SCALED_SKULL_PUR) : 256;
update_level[1][update_row] = 0x100 - ((led_level[1][led_index] * update_scaler) >> 8);
// updating the matrix is glitchy as best and I know I am doing something wrong here.
// but this is the best I could come up with while sleep-deprived forceful debugging.
// disable PWM
TIM_Cmd(led_pwm[0], DISABLE);
TIM_Cmd(led_pwm[1], DISABLE);
// set new PWM value for the active row
led_pwm_set_oc(led_pwm[0], update_level[0]);
led_pwm_set_oc(led_pwm[1], update_level[1]);
// reset pwm counter (fixes matrix glitches)
TIM_SetCounter(led_pwm[0], 0xff);
TIM_SetCounter(led_pwm[1], 0xff);
// generate update event to apply pwm values
TIM_GenerateEvent(led_pwm[0], TIM_EventSource_Update);
TIM_GenerateEvent(led_pwm[1], TIM_EventSource_Update);
// clear all columns
// we do this after setting PWM to fix glitchy other LEDs lighting
GPIO_ResetBits(led_col_port[0], led_col_pin_mask[0]);
GPIO_ResetBits(led_col_port[1], led_col_pin_mask[1]);
// and now set the active column
GPIO_SetBits(led_col_port[0], (1 << (led_col_pin_low[0] + update_col)));
GPIO_SetBits(led_col_port[1], (1 << (led_col_pin_low[1] + update_col)));
// re-enable PWM
TIM_Cmd(led_pwm[0], ENABLE);
TIM_Cmd(led_pwm[1], ENABLE);
}
void led_matrix_set_mode(uint8_t mode)
{
led_matrix_mode = mode;
}
void led_matrix_set_program(uint8_t program_idx, uint8_t init,
uint16_t wait, uint16_t level, uint32_t offset, uint32_t settings)
{
// we need to be in program mode
led_matrix_set_mode(LED_MATRIX_MODE_PROGRAM);
// update the program pointer
led_program = led_program_list[program_idx];
// set initial program variables
led_prog_set_wait = wait;
led_prog_set_level = level;
led_prog_set_offset = offset;
led_prog_set_option = settings;
// is this a new set? if so, initialize program parameters
if (init) {
int i;
led_prog_wait = 0;
for (i = 0; i < 4; i++) {
led_prog_state[i] = 0;
led_prog_work[i] = 0;
}
}
}
uint8_t led_matrix_get_mode()
{
return led_matrix_mode;
}
void led_matrix_mode_update()
{
int i;
switch (led_matrix_mode) {
case LED_MATRIX_MODE_PROGRAM: {
// if we have a valid program loaded, run it
if (led_program != NULL) {
led_program();
}
break;
}
case LED_MATRIX_MODE_OFF: {
led_program = NULL;
for (i = 0; i < 16; i++) {
led_level[LED_MATRIX_WHITE][i] = 0;
led_level[LED_MATRIX_PURPLE][i] = 0;
}
break;
}
}
}

View File

@ -0,0 +1,52 @@
/*
* led_matrix.h: main skull led matrix handling prototypes
* 2014 true
*
* ----
*
* $Id: led_matrix.h 364 2015-06-12 04:44:55Z true $
*
**/
#ifndef __PIRATE_LED_MATRIX_H
#define __PIRATE_LED_MATRIX_H
/* struct */
typedef struct LEDFixedPattern {
uint16_t wait;
uint32_t led[8];
} LEDFixedPattern;
/* constants */
#define LED_MATRIX_PROG_COUNT 6
/* interface */
#define LED_MATRIX_WHITE 0
#define LED_MATRIX_PURPLE 1
/* programs */
#define LED_MATRIX_MODE_OFF 0
#define LED_MATRIX_MODE_PROGRAM 2
/* variables */
extern const char led_matrix_prog_name[LED_MATRIX_PROG_COUNT][16];
/* prototypes */
void led_matrix_io_init();
void led_matrix_io_disable();
void led_matrix_next();
void led_matrix_mode_update();
void led_matrix_set_mode(uint8_t mode); // used for turning off
void led_matrix_set_program(uint8_t program_idx, uint8_t init,
uint16_t wait, uint16_t level, uint32_t offset, uint32_t settings);
#endif

View File

@ -0,0 +1,58 @@
/**
* led_matrix_pattern.h: fixed patterns for the RGBLED eyes
* 2014 by true
*
* ----
*
* $Id: led_matrix_pattern.h 327 2015-02-18 04:43:42Z true $
*
**/
// all LEDs on 100%
static const LEDFixedPattern led_pattern_01[] = {
{1000, {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}},
};
// all LEDs on 50%
static const LEDFixedPattern led_pattern_02[] = {
{1000, {0x7d7d7d7d, 0x7d7d7d7d, 0x7d7d7d7d, 0x7d7d7d7d,
0x7d7d7d7d, 0x7d7d7d7d, 0x7d7d7d7d, 0x7d7d7d7d}},
};
// alternate, fast fade
static const LEDFixedPattern led_pattern_03[] = {
{600, {0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
0x00ff00ff, 0x00ff00ff, 0x00ff00ff, 0x00ff00ff}},
{80, {0x80808080, 0x80808080, 0x80808080, 0x80808080,
0x80808080, 0x80808080, 0x80808080, 0x80808080}},
{600, {0x00ff00ff, 0x00ff00ff, 0x00ff00ff, 0x00ff00ff,
0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00}},
{80, {0x80808080, 0x80808080, 0x80808080, 0x80808080,
0x80808080, 0x80808080, 0x80808080, 0x80808080}}
};
// fast white/alternate flash
static const LEDFixedPattern led_pattern_04[] = {
{80, {0x34343434, 0x34343434, 0x34343434, 0x34343434,
0xa0a0a0a0, 0xa0a0a0a0, 0xa0a0a0a0, 0xa0a0a0a0}},
{80, {0x04040404, 0x04040404, 0x04040404, 0x04040404,
0xfdfdfdfd, 0xfdfdfdfd, 0xfdfdfdfd, 0xfdfdfdfd}},
{80, {0x78787878, 0x78787878, 0x78787878, 0x78787878,
0x86868686, 0x86868686, 0x86868686, 0x86868686}},
{80, {0xa0a0a0a0, 0xa0a0a0a0, 0xa0a0a0a0, 0xa0a0a0a0,
0x34343434, 0x34343434, 0x34343434, 0x34343434}},
{80, {0xfdfdfdfd, 0xfdfdfdfd, 0xfdfdfdfd, 0xfdfdfdfd,
0x04040404, 0x04040404, 0x04040404, 0x04040404}},
{80, {0x86868686, 0x86868686, 0x86868686, 0x86868686,
0x78787878, 0x78787878, 0x78787878, 0x78787878}}
};
// pattern count - make sure this is updated with the amount
// of entries in the patterns above!
static const uint8_t led_pattern_size[] = {
1,
1,
4,
6
};

View File

@ -0,0 +1,300 @@
/**
* led_matrix_prog.h: programs for the main LED matrix
* 2014 by true
*
* ----
*
* $Id: led_matrix_prog.h 364 2015-06-12 04:44:55Z true $
*
**/
// program variables
static uint16_t led_prog_wait; // used by function to keep track of iteration time
static uint32_t led_prog_state[4]; // used by the function to keep track of lit LEDs, state
static uint32_t led_prog_work[4]; // used for misc shit
static uint16_t led_prog_set_wait; // used by setter function to set iteration time in ms
static uint16_t led_prog_set_level; // used by setter function to set desired level
static uint32_t led_prog_set_offset;// used by setter function to set desired offset
static uint32_t led_prog_set_option;// used by setter to set options
/* programs */
/********
* debug light output
* uses white LEDs as debug output.
* set the offset to the LED mask for LEDs you want lit.
* set the wait time to the time to stay lit (15000 is a good value).
*********/
static void led_prog_debug()
{
int i;
if (led_prog_set_wait) {
led_prog_wait = led_prog_set_wait;
led_prog_set_wait = 0;
led_prog_state[0] = led_prog_set_offset;
}
if (led_prog_wait) {
led_prog_wait--;
}
for (i = 0; i < 16; i++) {
if (led_prog_state[0] & (1 << i)) {
led_level[0][i] = led_prog_wait ? (led_prog_set_level & 0xff) : 0;
} else {
led_level[0][i] = 0;
}
}
}
/********
* around the skull in a loop program
* speed: set as desired
* options: bit 0 = white enable, bit 1 = purple enable,
* bit 2 = white direction (0 = clockwise, 1 = counter-clockwise),
* bit 3 = purple direction (0 = clockwise, 1 = counter-clockwise),
* bit 4 = decay trails faster, bit 5 = decay trails even faster,
* bit 6 = trails enable on white, bit 7 = trails enable on purple
*********/
static void led_prog_loops()
{
int i;
// timeout is done?
if (!led_prog_wait) {
// load new timer wait value
led_prog_wait = led_prog_set_wait * 5;
// set decay rate (LED PWM active values are right shifted by this value)
led_prog_work[0] = 1;
if (led_prog_set_option & BIT_4) led_prog_work[0]++;
if (led_prog_set_option & BIT_5) led_prog_work[0] += 2;
// set initial LED offsets
if (!led_prog_work[3]) {
led_prog_state[0] = led_prog_set_offset & 0x0f;
led_prog_state[1] = (led_prog_set_offset >> 4) & 0x0f;
led_prog_work[3] = 1;
}
// set LED PWM levels
for (i = 0; i < 16; i++) {
if ((i == led_prog_state[0]) && (led_prog_set_option & BIT_0)) {
// LED is active and enabled; set to desired level.
led_level[0][i] = led_prog_set_level & 0xff;
} else {
// led is not active - decay if trails on, otherwise turn off
led_level[0][i] = (led_prog_set_option & BIT_6) ?
led_level[0][i] >> led_prog_work[0] : 0;
}
if ((i == led_prog_state[1]) && (led_prog_set_option & BIT_1)) {
// LED is active and enabled; set to desired level.
led_level[1][i] = led_prog_set_level >> 8;
} else {
// led is not active - decay if trails on, otherwise turn off
led_level[1][i] = (led_prog_set_option & BIT_7) ?
led_level[1][i] >> led_prog_work[0] : 0;
}
}
// update program state with the next LED
for (i = 0; i < 2; i++) {
led_prog_state[i] += (led_prog_set_option & (1 << (i + 2))) ? 15 : 1;
led_prog_state[i] &= 0x0f;
}
}
// bide our time...
led_prog_wait--;
}
/********
* around the skull in a loop program modulated by microphone
* speed: set as desired
* options: see above program
*********/
static void led_prog_loops_mic()
{
static uint32_t delay = 0;
uint16_t low, high;
low = (led_prog_set_offset >> 8) & 0xff;
high = (led_prog_set_offset >> 16) & 0xff;
led_prog_state[3] = pirate_scale(mic_peak, settings.mic_cal[0], settings.mic_cal[1], 255, 0);
led_prog_state[3] = pirate_scale(led_prog_state[3], low, high, 1, 120);
// variable decay
if (!delay) {
delay = (led_prog_set_offset >> 24);
if (!delay) delay = 1;
if (led_prog_set_wait < led_prog_state[3]) {
led_prog_set_wait++;
}
}
// always have fast attack
if (led_prog_set_wait > led_prog_state[3]) {
led_prog_set_wait = led_prog_state[3];
}
delay--;
led_prog_loops();
}
/********
* around the skull in a loop program that rotates
* most useful for oppositing direction loops so that the
* point of contact changes
* speed: set as desired
* options: see above program, with the following:
* high 12 option bits: time between rotating in ms
* bits[19:16]: specify direction (1-15 = move pos cw)
*********/
static void led_prog_loops_rotate()
{
static uint32_t wait = 0;
uint32_t t;
if (!wait) {
wait = (led_prog_set_option >> 20) * 5;
if (!wait) wait = 1;
t = (led_prog_set_option >> 16 & 0x0f);
if (t >= 1 && t <= 15) {
led_prog_state[0] += t;
led_prog_state[0] &= 0x0f;
led_prog_state[1] += t;
led_prog_state[1] &= 0x0f;
}
}
wait--;
led_prog_loops();
}
/********
* random on, random off
* speed: set as desired
* options: bit 7 = fade off instead of turning off, bit 6 = fade faster
* bit 5 = fade even faster, bit 4 = fade faster still
* bit 1 = enable purple, bit 0 = enable white
*********/
static void led_prog_rand_on_rand_off()
{
int i;
uint8_t fade;
if (!led_prog_wait) {
// load new timer wait value
led_prog_wait = led_prog_set_wait * 5;
// is this a new run?
if (!led_prog_state[3]) {
led_prog_state[3] = 1;
for (i = 0; i < 16; i++) {
led_level[LED_MATRIX_WHITE][i] = 0;
led_level[LED_MATRIX_PURPLE][i] = 0;
}
}
led_prog_state[0] = led_prog_state[0] ? 0 : 1;
fade = 0;
if (led_prog_set_option & 0x80) fade = 2;
if (led_prog_set_option & 0x40) fade += 6;
if (led_prog_set_option & 0x20) fade += 12;
if (led_prog_set_option & 0x10) fade += 24;
for (i = 0; i < 16; i++) {
if (fade) {
if (led_level[LED_MATRIX_WHITE][i] > fade) {
led_level[LED_MATRIX_WHITE][i] -= fade;
} else {
led_level[LED_MATRIX_WHITE][i] = 0;
}
if (led_level[LED_MATRIX_PURPLE][i] > fade) {
led_level[LED_MATRIX_PURPLE][i] -= fade;
} else {
led_level[LED_MATRIX_PURPLE][i] = 0;
}
} else {
led_level[LED_MATRIX_WHITE][i] = 0;
led_level[LED_MATRIX_PURPLE][i] = 0;
}
}
if (led_prog_set_option & (1 << led_prog_state[0])) {
led_level[led_prog_state[0]][pirate_prng() % 16] = led_prog_set_level >> (led_prog_state[0] << 3);
}
}
led_prog_wait--;
}
/********
* impulse spl meter
* speed: ignored
* options: bits7-0 = sensitivity
*********/
static void led_prog_mic_spl_meter()
{
int i;
uint8_t set[2];
if (!led_prog_wait) {
led_prog_wait = led_prog_set_wait * 5;
if (led_prog_work[0] > mic_peak) {
led_prog_work[0] -= 4;
} else {
led_prog_work[0] = mic_peak;
}
// scale peak value to calculated value and invert it
led_prog_state[3] = pirate_scale(led_prog_work[0], settings.mic_cal[0], settings.mic_cal[1], 0, 255);
// and invert it
led_prog_state[3] ^= 0xff;
// set defaults high level if not set
if (!(led_prog_set_option >> 24)) led_prog_set_option |= (0xff << 24);
// stretch value with constrained bounds to original bounds
led_prog_state[3] = pirate_scale(led_prog_state[3],
(led_prog_set_option >> 16) & 0xff, (led_prog_set_option >> 24), 0, 255);
// finally determine which LEDs to light
led_prog_state[3] = pirate_scale(led_prog_state[3], 0, 255, 0, 8);
// then set them
for (i = 0; i < 8; i++) {
if (led_prog_state[3] < i) {
set[0] = led_prog_set_level & 0xff;
set[1] = led_prog_set_level >> 8;
} else if (led_prog_state[3] == i) {
set[0] = (led_prog_set_level & 0xff) >> 1;
set[1] = led_prog_set_level >> 9;
} else {
set[0] = 0;
set[1] = 0;
}
led_level[LED_MATRIX_WHITE][i] = set[0];
led_level[LED_MATRIX_WHITE][15 - i] = set[0];
led_level[LED_MATRIX_PURPLE][i] = set[1];
led_level[LED_MATRIX_PURPLE][15 - i] = set[1];
}
}
led_prog_wait--;
}

View File

@ -0,0 +1,659 @@
/**
* Whiskey Pirates DC22 Badge "PIRATE CPU" Firmware
* MCU firmware for STM32L100RBT6
* Originally written 2014 by true, updates in 2015 for DC23 by true
* Created: 2014.05.16
* ts:4
*
* ----
*
* ISR Usage ~13% average, 26% max (as of rev186)
* Yeah, some of this shit is hackish. What do you expect from a hacker.
* I'm sorry for some of the shit in here, 90% was written while sleep-deprived
* plus I don't know wtf I am doing -- true
*
**/
/* pirates */
#include "pirate.h" // cmsis include is located here
#include "interface/gpio.h"
#include "interface/led_pwm.h"
#include "interface/adc.h"
#include "interface/i2c.h"
#include "device/lcd.h"
#include "device/beep.h"
#include "device/attiny.h"
#include "device/lightsensor.h"
#include "device/radio/nrf.h"
#include "led/led_matrix.h"
#include "led/led_bone.h"
#include "menu/lcd_menu.h"
#include "menu/menu_settings.h" // settings_restore() lives here
#include "menu/menu_program.h" // LED program related shit lives here
#include "display/infopirate.h"
/* usb cdc serial port support */
#include "usb/core/usb_lib.h"
#include "usb/glue.h"
// hard buttons
static const tGPIO btn[4] = {
{GPIOC, GPIO_Pin_0, 0},
{GPIOA, GPIO_Pin_15, 15},
{GPIOC, GPIO_Pin_1, 1},
{GPIOB, GPIO_Pin_2, 2},
};
#define BTN_DEBOUNCE_CYCLES 30
static const uint8_t btn_hilevel = 0b00001000; // button is active high when its bit is set, otherwise active low
uint16_t btn_press[4];
uint16_t btn_hold[4];
// main handler timer timekeeping
uint32_t tim6_count;
uint32_t tim6_usage; // profiling
/* functions */
/********
* initialize main handler interrupt
********/
void pirate_tim6_init()
{
TIM_TimeBaseInitTypeDef tim_tb;
NVIC_InitTypeDef nvic;
// enable peripheral clock
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
// set up to fire 0.2ms main handler loop (2.5KHz, ~12800 clocks per cycle)
// LED light rate for main LED matrix looprate/16 (for 16 LEDs per matrix), which is 156Hz...
TIM_TimeBaseStructInit(&tim_tb);
tim_tb.TIM_Period = (SystemCoreClock / 2500) - 1;
TIM_TimeBaseInit(TIM6, &tim_tb);
// enable interrupt
TIM_ITConfig(TIM6, TIM_IT_Update, ENABLE);
// set as highest priority - this is our UI handler too
nvic.NVIC_IRQChannel = TIM6_IRQn;
nvic.NVIC_IRQChannelPreemptionPriority = 2;
nvic.NVIC_IRQChannelSubPriority = 1;
nvic.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&nvic);
// finally, enable the timer
TIM_Cmd(TIM6, ENABLE);
// make sure our profiling variable doesn't get optimized away
__asm__ __volatile__("" :: "m" (tim6_usage));
}
/********
* initialize gpio for buttons
* this assumes the GPIOs are clocked already
********/
static inline void btn_init()
{
GPIO_InitTypeDef gpio;
int i;
gpio.GPIO_Mode = GPIO_Mode_IN;
gpio.GPIO_Speed = GPIO_Speed_400KHz;
for (i = 3; i >= 0; i--) {
if (btn_hilevel & (1 << i)) {
gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
} else {
gpio.GPIO_PuPd = GPIO_PuPd_UP;
}
gpio.GPIO_Pin = btn[i].pin;
GPIO_Init(btn[i].port, &gpio);
}
// set initial button types to operate the main menu
// TODO: maybe this won't do this and it'll instead run the program by default
menu_btntype_menus();
}
/********
* default button push handlers
* TODO: implement what is necessary to make these more useful
********/
static inline void btn_evt_push(uint16_t btn)
{
if (lcd_btn_fn[btn]) {
lcd_btn_fn[btn]();
}
}
static inline void btn_evt_hold(uint16_t btn, uint16_t count)
{
if (btn == BTN_UP || btn == BTN_DOWN) {
if (!(count == 0 || count == 2)) {
btn_evt_push(btn);
}
}
}
static inline void btn_evt_release(uint16_t btn)
{
return;
}
/********
* update the state of pressed buttons
********/
static inline void btn_update()
{
int i;
int pressed;
for (i = 0; i < 4; i++) {
pressed = 0;
// button high or low?
if (btn_hilevel & (1 << i)) {
if (btn[i].pin & GPIO_ReadInputData(btn[i].port)) pressed = 1;
} else {
if (!(btn[i].pin & GPIO_ReadInputData(btn[i].port))) pressed = 1;
}
if (pressed) {
btn_press[i]++;
if (btn_press[i] == BTN_DEBOUNCE_CYCLES) {
// button is pushed
btn_evt_push(i);
} else if (btn_press[i] == 1500) {
// btn is held
btn_evt_hold(i, btn_hold[i]);
// btn is held for 0.3s (or re-fired 0.1s)
btn_hold[i]++;
// we only uniquely count 30 seconds of hold...
if (btn_hold[i] > 30000) {
btn_hold[i] = 30000;
}
// reset to re-fire in 0.1s increments
btn_press[i] = 1000;
}
// done handling buttons - we only do one pressed at a time right now
break;
} else {
// if pushed, fire release event
if (btn_press[i] > BTN_DEBOUNCE_CYCLES) {
btn_evt_release(i);
}
// reset pushed state
btn_press[i] = 0;
btn_hold[i] = 0;
}
}
}
/* startup */
int main(void)
{
int i;
// update clock info
SystemCoreClockUpdate();
// enable gpio clocks
// enable peripheral clocks
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
// set up LED matrix GPIO and clocks
led_matrix_io_init();
// set up bone LED GPIO and clocks
led_bone_io_init();
// set up LED PWM peripherals
led_pwm_init_all();
// set up buttons
btn_init();
// read settings from EEPROM
// NOTE: MENU button will load default settings (but keep name)
// NOTE: MENU+OK will also erase name, restoring all defaults
// TODO: separate programs from this, have another combo for erasing programs
i = (GPIO_ReadInputDataBit(btn[BTN_MENU].port, btn[BTN_MENU].pin)) ? 0x00 : 0x01;
if (i) i |= (GPIO_ReadInputDataBit(btn[BTN_OK].port, btn[BTN_OK].pin)) ? 0x00 : 0x02;
settings_restore(i);
// set up program run variables
prog_init();
// set up ADC
adc_init();
// set up I2C master peripheral (pegleg and LCD comms)
i2c_init(I2C2, 400000);
// wait some more time for pegleg to boot. it can take a while
pirate_delay(10);
// set up LCD
lcd_init();
lcd_cmd(LCD_CMD_CLEAR_SCREEN);
// set up LCD menus
lcd_menu_init();
// set up LCD backlight
lcd_led_init();
// set up USB
USB_ClockEna();
USB_Interrupts_Config();
USB_Init_System();
pirate_delay(10); // need to wait a bit, if we start up too fast host won't find device
USB_Init();
// set up magical beeper
beep_init();
// and play startup tone
beep(26, 40);
beep(31, 40);
beep(30, 40);
beep(29, 40);
beep(28, 40);
// need to wait some more for NRF to be ready to configure
// this is per datasheet; it is probably actually working by now
pirate_delay(50);
// set up the radio
nrf_init();
// set up pegleg light sensor gain
if (settings.light_setgain) {
// we have a fixed gain set
light_gain = settings.light_setgain;
attiny_write_light_sensitivity(0, light_gain);
} else {
// we don't have a fixed gain, so load a default gain value
light_gain = LIGHTSENS_THRESH_TOP_NORM;
attiny_write_light_sensitivity(0, LIGHTSENS_THRESH_TOP_NORM);
}
// set up main handler interrupt
pirate_tim6_init();
// after system is booted, we can enable the prefetch buffer
// for some reason, at 32MHz, power glitches could cause some
// freak out when booting if we turned this on any earlier
FLASH->ACR |= FLASH_ACR_PRFTEN;
while (1) {
// update clock info
SystemCoreClockUpdate();
// update various low-priority things
if (tim6_count % 500 == 0) {
static volatile uint32_t update = 0;
update++;
if (update == 20) update = 0;
switch (update) {
case 1: { // light sensor
// TODO: investigate the bug that causes this to read ~70-80 when it
// should be reading >100
if ((settings.led_autoadjust & 0x80) || settings.lcd_autobrite) {
if (!settings.light_setgain) {
light_level = attiny_read_light_level(0);
}
} else {
light_level = settings.led_autogain_lev_max - 1;
}
break;
}
case 2: {
// auto-update light sensor gain
if (!settings.light_setgain) {
if (lightsensor_gainvalue_update()) {
// updated, so send updated value
attiny_write_light_sensitivity(0, light_gain);
}
} else {
light_gain = settings.light_setgain;
}
break;
}
case 3:
case 13: { // temp sensor
pirate_thermometer_log(attiny_read_temp());
break;
}
}
}
// max update 50 times/second
if (tim6_count % 50 == 8) {
// update eyes
led_eyes_tx();
// update LCD contrast
lcd_apply_contrast();
// update LCD CGRAM
if (lcd_cgram_len) {
// set LCD height
// make sure in your code that you set this to CGRAM mode!
lcd_cmd(lcd_get_height());
// only update CGRAM if we are in CGRAM mode
if ((lcd_get_height() & 0x01) == 0) {
// make sure to force updating the mode again
lcd_cmd(lcd_get_height());
// and update CGRAM contents
for (i = 0; i < lcd_cgram_len; i++) {
lcd_print(0x40 + (i << 3), lcd_cgram[i], 8);
}
lcd_cgram_len = 0;
}
} else {
// set LCD height
// this is here like this to fix compiler optimization bug?
// TODO: find out wtf I meant by this
lcd_cmd(lcd_get_height());
}
// update LCD characters
lcd_linebuf_send();
// set the LCD cursor position and type
lcd_cmd(lcd_get_cursor_type());
lcd_cmd(lcd_get_cursor_pos());
}
// update battery voltage info 10 times/second
if (tim6_count % 250 == 248) {
pirate_batt_log(adc_result[ADC_READ_BATT_VOLTAGE]);
}
// then go to sleep
__WFI();
}
return(0);
}
/* ISR */
// main handler interrupt
void TIM6_IRQHandler()
{
int i, j, k, n;
static uint16_t nametx;
// update counter
tim6_count++;
if (tim6_count >= 2500) {
tim6_count = 0;
}
// manage buttons
btn_update();
// update ADC values, currently 2.5KHz
if ((tim6_count & 0x01) == 0x01) {
adc_start();
}
// update LED mic peak
// mic peak decaying
if ((tim6_count & 0x03) == 0x03) {
if (mic_peak > adc_result[ADC_READ_MIC_PEAK]) {
mic_peak--;
} else {
mic_peak = adc_result[ADC_READ_MIC_PEAK];
}
}
// update autoadjust value for LEDs, polls 25 times/second (40ms)
if (tim6_count % 200 == 0) {
uint8_t brightness;
// always need to run this as the LCD might use it
lightsensor_scaler_update();
// backlight LCD is a little different
brightness = settings.lcd_autobrite ?
lightsensor_get_scalerval(LIGHTSENS_SCALED_BACKLIGHT) : settings.lcd_brightness;
lcd_led_set_level(brightness, 1);
}
// update LCD backlight
lcd_led_update();
// update main matrix LEDs
led_matrix_mode_update();
led_matrix_next();
// update bone matrix LEDs
led_bone_mode_update();
led_bone_next();
// update eyes RGBLEDs
led_eyes_mode_update();
// update beeper
beep_update();
// update LCD data 100Hz
// yes, we only update it at 50Hz. but timings use 100Hz timings.
if (tim6_count % 50 == 0) {
if (menuc == (MenuItem *)&menu_runitem) {
// run mode display
infopirate_update();
} else {
// info display
lcd_menu_update();
}
}
// runmode program
if (tim6_count == 0) {
for (i = 0; i < 3; i++) {
if (!(
(menu_mode == MENU_MODE_RUNNING_PROGRAM)
|| (menu_mode == MENU_MODE_PROGRAM_EDITOR)
|| settings.autorun & 0x02)) {
// we aren't running the program or editing, so stop everything
prog_id[i] = 255;
switch (i) {
case PROG_TYPE_SKULL: {
led_matrix_set_mode(LED_MATRIX_MODE_OFF);
break;
}
case PROG_TYPE_BONES: {
led_bone_set_mode(LED_MATRIX_MODE_OFF);
break;
}
case PROG_TYPE_EYES: {
// only stop eyes if not in favcolor editor
if (!(menuc->root == &menu_pref_ritem[1])) {
led_eyes_set_mode(LED_EYES_MODE_OFF);
}
}
}
} else {
// we're running the program or editing a program. update the display
if (prog_dwell[i] > 0) {
prog_dwell[i]--;
}
if (prog_dwell[i] == 0) {
if (menu_mode == MENU_MODE_PROGRAM_EDITOR) {
// if we are editing, set up what we are trying to edit for preview
n = menu_prog_get_type();
j = menu_prog_get_idx();
k = (prog_id[n] == 255 || (settings.led_prog[n][j].type & 0x02)) ? 1 : 0;
prog_id[i] = 0;
prog_dwell[i] = k ? (settings.led_prog[n][j].dwell << 1) : k;
switch (n) {
case PROG_TYPE_SKULL: {
led_matrix_set_program(
settings.led_prog[0][j].progidx,
k,
settings.led_prog[0][j].wait,
settings.led_prog[0][j].level,
settings.led_prog[0][j].offset,
settings.led_prog[0][j].option
);
break;
}
case PROG_TYPE_BONES: {
led_bone_set_program(
settings.led_prog[1][j].progidx,
k,
settings.led_prog[1][j].wait,
settings.led_prog[1][j].level,
settings.led_prog[1][j].offset,
settings.led_prog[1][j].option
);
break;
}
case PROG_TYPE_EYES: {
led_eyes_set_program(
settings.led_prog[2][j].progidx,
k,
settings.led_prog[2][j].wait,
settings.led_prog[2][j].level,
settings.led_prog[2][j].offset,
settings.led_prog[2][j].option
);
break;
}
}
} else {
// we must be trying to run the program. show it all.
j = PIRATE_PROG_SAVED_MAX + 1;
k = prog_id[i];
while (j) {
j--;
prog_id[i]++;
if (prog_id[i] >= PIRATE_PROG_SAVED_MAX) prog_id[i] = 0;
if (settings.led_prog[i][prog_id[i]].type & 0x80) {
// we have an enabled program
break;
}
}
if (j) {
// load new program if it doesn't match the old program
// or if a program was never run (such as at reboot)
if (prog_get_mode(i) == 1) {
k = (k == 255 || (settings.led_prog[i][prog_id[i]].type & 0x02)) ? 1 : 0;
// program change check: (settings.led_prog[i][prog_id[i]].progidx != k)
prog_dwell[i] = (settings.led_prog[i][prog_id[i]].dwell << 1);
switch (i) {
case PROG_TYPE_SKULL: {
led_matrix_set_program(
settings.led_prog[0][prog_id[0]].progidx,
k,
settings.led_prog[0][prog_id[0]].wait,
settings.led_prog[0][prog_id[0]].level,
settings.led_prog[0][prog_id[0]].offset,
settings.led_prog[0][prog_id[0]].option
);
break;
}
case PROG_TYPE_BONES: {
led_bone_set_program(
settings.led_prog[1][prog_id[1]].progidx,
k,
settings.led_prog[1][prog_id[1]].wait,
settings.led_prog[1][prog_id[1]].level,
settings.led_prog[1][prog_id[1]].offset,
settings.led_prog[1][prog_id[1]].option
);
break;
}
case PROG_TYPE_EYES: {
led_eyes_set_program(
settings.led_prog[2][prog_id[2]].progidx,
k,
settings.led_prog[2][prog_id[2]].wait,
settings.led_prog[2][prog_id[2]].level,
settings.led_prog[2][prog_id[2]].offset,
settings.led_prog[2][prog_id[2]].option
);
break;
}
}
}
}
}
}
}
}
}
// send nametx packet
if (dc23_nametx && tim6_count % 500 == 4) {
if (nametx == 2) {
// send first packet
nrf_tx_buf[0] = NRF_CMD_DC22_23GREET;
nrf_tx_buf[1] = 22;
nrf_tx_buf[2] = 0;
for (i = 0; i < 4; i++) {
nrf_tx_buf[3 + i] = settings.name[i];
}
nrf_tx_buf[7] = nrf_checksum(nrf_tx_buf, 7, 0);
nRF24_packet_tx(nrf_tx_buf, NRF_PAYLOAD_LEN, 1);
} else if (nametx == 1) {
// send second packet
nrf_tx_buf[0] = NRF_CMD_DC22_23GREET;
nrf_tx_buf[1] = 22;
nrf_tx_buf[2] = 1;
for (i = 0; i < 4; i++) {
nrf_tx_buf[3 + i] = settings.name[4 + i];
}
nrf_tx_buf[7] = nrf_checksum(nrf_tx_buf, 7, 0);
nRF24_packet_tx(nrf_tx_buf, NRF_PAYLOAD_LEN, 1);
}
if (nametx) {
nametx--;
} else {
nametx = dc23_nametx * 600;
}
}
// profiling: get current counter value
tim6_usage = tim6_usage;
tim6_usage = TIM6->CNT;
// clear interrupt bit
TIM_ClearITPendingBit(TIM6, TIM_IT_Update);
}

View File

@ -0,0 +1,735 @@
/**
* lcd_menu.c: lcd menuing functions, in particular editing functions
* 2014 by true
*
* ----
*
* $Id: lcd_menu.c 368 2015-06-16 06:49:48Z true $
*
**/
#include <pirate.h>
#include "../interface/i2c.h" // for writing tempcal to attiny
#include "../device/lcd.h" // lcd constants, modes and buffer routines
#include "../device/attiny.h" // for temperature offset editing
#include "../device/lightsensor.h" // for light gain editing
#include "../device/beep.h" // for letting you know you did something
#include "../display/infopirate.h"
#include "lcd_menu.h"
#include "menu_radio.h" // all the various submenu helper functions and root menu declarations
#include "menu_settings.h" // editing handlers are in this file though
#include "menu_program.h" // the actual submenus are in their respective files
#include "menu_sensors.h" // this is what happens when sleep deprived
#include "menu_testing.h"
#include "menu_credits.h"
/* lcd */
MenuItem *menuc;
uint8_t menu_mode;
static uint16_t line_idx[2] = {0xffff, 0xffff};
static uint16_t line_time[2] = {0, 0};
static uint8_t lcd_fn_time = 0;
static char lcd_fn_output[64];
void (*lcd_btn_fn[4])();
/* menus */
uint16_t menu_editing;
uint32_t menu_oldval;
uint32_t menu_newval;
const MenuItem menu_runitem; // used for run mode
/* functions */
void lcd_menu_init()
{
// initial menu
if (settings.autorun & 0x01) {
menuc = (MenuItem *)&menu_runitem;
menu_root_run(0);
} else {
menuc = (MenuItem *)&menu_ritem[0];
menu_btntype_menus();
}
}
void lcd_menu_set(const MenuItem *set)
{
menuc = (MenuItem *)set;
}
void lcd_menu_linescroll_reset(uint8_t idx)
{
line_time[idx] = 0;
line_idx[idx] = 0xffff;
}
static uint8_t lcd_menu_linescroll(uint8_t idx, char *dst, char *src, uint8_t maxlen,
uint8_t spaces, uint16_t time_wait, uint16_t time_run)
{
int i;
int len;
char *cpy;
uint16_t copied = 0;
len = strlen(src);
// is this line too long?
if (len > maxlen) {
// begin scrolling.
// if timeout occurred, update the index
if (line_time[idx] == 0) {
// set the pause time based on the max length plus padding spaces
// if we are over this limit, we are in "start over" phase and need to use that delay
if (line_idx[idx] > len + spaces) {
// this is where we start or start over
line_time[idx] = time_wait;
line_idx[idx] = 0;
} else {
// we are in normal continuing phase, use the continuing delay and increment index
line_time[idx] = time_run;
line_idx[idx]++;
}
}
line_time[idx]--;
// figure out how much to copy
cpy = src + line_idx[idx];
len = ((len - maxlen) > line_idx[idx]) ?
maxlen :
len - line_idx[idx];
// copy up to and including the trailing edge of the text
if (len > 0) {
for (i = 0; i < len && copied < maxlen; i++) {
*dst++ = *cpy++;
copied++;
}
}
// if we have more left than the length provided, we are done
if (len >= maxlen) {
return maxlen;
}
// otherwise, we need to add some spaces
i = spaces;
if (len < 0) {
i += len;
}
// copy the spaces into the stream
if (i) {
for (; i > 0 && (copied < maxlen); i--) {
*dst++ = 0x20;
copied++;
}
}
// and, if we have room, copy starting from the beginning of the source
while (copied < maxlen) {
*dst++ = *src++;
copied++;
}
return maxlen;
} else {
// nope, just copy directly
strncpy(dst, src, maxlen);
return len;
}
}
void lcd_menu_update()
{
int line_len;
int i;
// header line static text
if (menuc->root == 0) {
lcd_menu_linescroll(0, lcd_line[0], LCD_ROOT_TEXT, LCD_MAX_LINE_LENGTH,
LCD_DEF_SPACING, LCD_DEF_SCROLL_WAIT, LCD_DEF_SCROLL_RUN);
} else if ((int)menuc->root > 255) {
lcd_menu_linescroll(0, lcd_line[0], menuc->root->this->disp, LCD_MAX_LINE_LENGTH,
menuc->root->this->scroll_spaces, menuc->root->this->scroll_time_wait,
menuc->root->this->scroll_time_run);
} else {
// maybe we can do other special shit here later
// if set to 255, then external tasks need to update this line
}
// TODO: show header line dynamic text? or flag?
// do we update the function-based string?
if (!lcd_fn_time) {
// reset the timeout value
lcd_fn_time = menuc->this->dispfn_delay;
// if there was no timeout value, we need to fake one
if (lcd_fn_time == 0) {
lcd_fn_time++;
}
// if there is a function attached, call it
if (menuc->this->dispfn != NULL) {
strncpy(lcd_fn_output, menuc->this->dispfn(menuc->this->disp_id), 63);
lcd_fn_output[63] = 0;
} else {
// no function? no data.
lcd_fn_output[0] = 0;
}
}
lcd_fn_time--;
// second line static text
line_len = lcd_menu_linescroll(1, lcd_line[1], menuc->this->disp, LCD_MAX_LINE_LENGTH,
menuc->this->scroll_spaces, menuc->this->scroll_time_wait, menuc->this->scroll_time_run);
// second line dynamic text
if (line_len < LCD_MAX_LINE_LENGTH) {
lcd_menu_linescroll(1, lcd_line[1] + line_len, lcd_fn_output, LCD_MAX_LINE_LENGTH - line_len,
menuc->this->scroll_spaces, menuc->this->scroll_time_wait, menuc->this->scroll_time_run);
}
// fix any nulls
for (i = 0; i < 9; i++) {
if (!lcd_line[0][i]) lcd_line[0][i] = 0x20;
if (!lcd_line[1][i]) lcd_line[1][i] = 0x20;
}
}
/* menu nav functions */
void menu_btn_next()
{
if (menuc->next != 0) {
lcd_menu_set(menuc->next);
lcd_menu_linescroll_reset(1);
lcd_fn_output[0] = 0;
if (settings.beeper) {
beep(settings.beep_type[0], 10);
}
}
}
void menu_btn_prev()
{
if (menuc->prev != 0) {
lcd_menu_set(menuc->prev);
lcd_menu_linescroll_reset(1);
lcd_fn_output[0] = 0;
if (settings.beeper) {
beep(settings.beep_type[0], 10);
}
}
}
void menu_btn_menu()
{
if (menuc->root) {
// call the root menu's entry function
if (menuc->root->this->entryfn != NULL) {
menuc->root->this->entryfn(menuc->root->this->entry_id);
}
// and set to that menu
lcd_menu_set(menuc->root);
lcd_menu_linescroll_reset(0);
lcd_menu_linescroll_reset(1);
lcd_fn_output[0] = 0;
if (settings.beeper) {
beep(settings.beep_type[0] - 1, 10);
}
}
menu_btntype_menus();
}
void menu_btn_ok()
{
// call this menu's entry function
if (menuc->this->entryfn != NULL) {
menuc->this->entryfn(menuc->this->entry_id);
if (settings.beeper) {
beep(settings.beep_type[0] + 1, 10);
}
}
// and set to the new menu if available
if (menuc->enter) {
lcd_menu_set(menuc->enter);
lcd_menu_linescroll_reset(0);
lcd_menu_linescroll_reset(1);
lcd_fn_output[0] = 0;
if (settings.beeper) {
beep(settings.beep_type[0], 10);
}
}
}
/* menu edit functions */
void menu_edit_next()
{
int work;
int do_beep = 0;
switch (menu_editing) {
case SETTING_NAME: {
break;
}
case SETTING_CONTRAST: {
if (menu_newval < 63) {
menu_newval++;
lcd_set_contrast(menu_newval);
do_beep = settings.beeper;
}
break;
}
case SETTING_FAVCOLOR_RED:
case SETTING_FAVCOLOR_GREEN:
case SETTING_FAVCOLOR_BLUE: {
if (menu_newval < 0xff) {
menu_newval++;
settings.fav_color[menu_editing - SETTING_FAVCOLOR_RED] = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SETTING_BEEP_TYPE_BUTTON:
case SETTING_BEEP_TYPE_PAGING:
case SETTING_BEEP_TYPE_ALARM: {
if (menu_newval < 30) {
menu_newval++;
settings.beep_type[menu_editing - SETTING_BEEP_TYPE_BUTTON] = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SENSOR_LIGHT_SETTINGSGAIN: {
if (menu_newval == 0) {
menu_newval = LIGHTSENS_GAIN_MIN;
do_beep = settings.beeper;
} else if (menu_newval < LIGHTSENS_GAIN_MAX) {
menu_newval++;
do_beep = settings.beeper;
}
settings.light_setgain = menu_newval;
break;
}
case SETTING_BRITE_LCD_VALUE: {
if (menu_newval < 200) {
menu_newval++;
settings.lcd_brightness = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SETTING_BRITE_AUTOGAIN_LO: {
if (menu_newval < 160) {
menu_newval++;
settings.led_autogain_lev_min = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SETTING_BRITE_AUTOGAIN_HI: {
if (menu_newval < 160) {
menu_newval++;
settings.led_autogain_lev_max = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SETTING_BRITE_THRESH0:
case SETTING_BRITE_THRESH1:
case SETTING_BRITE_THRESH2:
case SETTING_BRITE_THRESH3:
case SETTING_BRITE_THRESH4: {
work = menu_editing - SETTING_BRITE_THRESH0;
if (menu_editing == SETTING_BRITE_THRESH4) {
work = LIGHTSENS_GAIN_MAX;
} else {
work = settings.led_autothresh[work + 1] - 1;
}
if (menu_newval < work) {
menu_newval++;
settings.led_autothresh[menu_editing - SETTING_BRITE_THRESH0] = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SENSOR_TEMP_CALVALUE: {
if (temperature_cal < 60) {
temperature_cal++;
do_beep = settings.beeper;
}
break;
}
}
if (do_beep) {
beep(settings.beep_type[0], 10);
}
}
void menu_edit_prev()
{
int work;
int do_beep = 0;
switch (menu_editing) {
case SETTING_NAME: {
break;
}
case SETTING_CONTRAST: {
if (settings.contrast) {
menu_newval--;
lcd_set_contrast(menu_newval);
do_beep = settings.beeper;
}
break;
}
case SETTING_FAVCOLOR_RED:
case SETTING_FAVCOLOR_GREEN:
case SETTING_FAVCOLOR_BLUE: {
if (menu_newval) {
menu_newval--;
settings.fav_color[menu_editing - SETTING_FAVCOLOR_RED] = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SETTING_BEEP_TYPE_BUTTON:
case SETTING_BEEP_TYPE_PAGING:
case SETTING_BEEP_TYPE_ALARM: {
if (menu_newval > 1) {
menu_newval--;
settings.beep_type[menu_editing - SETTING_BEEP_TYPE_BUTTON] = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SENSOR_LIGHT_SETTINGSGAIN: {
if (menu_newval > LIGHTSENS_GAIN_MIN) {
menu_newval--;
do_beep = settings.beeper;
} else if (menu_newval == LIGHTSENS_GAIN_MIN) {
menu_newval = 0;
do_beep = settings.beeper;
}
settings.light_setgain = menu_newval;
break;
}
case SETTING_BRITE_LCD_VALUE: {
if (menu_newval) {
menu_newval--;
settings.lcd_brightness = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SETTING_BRITE_AUTOGAIN_LO: {
if (menu_newval > 0) {
menu_newval--;
settings.led_autogain_lev_min = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SETTING_BRITE_AUTOGAIN_HI: {
if (menu_newval > 0) {
menu_newval--;
settings.led_autogain_lev_max = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SETTING_BRITE_THRESH0:
case SETTING_BRITE_THRESH1:
case SETTING_BRITE_THRESH2:
case SETTING_BRITE_THRESH3:
case SETTING_BRITE_THRESH4: {
work = menu_editing - SETTING_BRITE_THRESH0;
if (!work) {
work = LIGHTSENS_GAIN_MIN;
} else {
work = settings.led_autothresh[work - 1] + 1;
}
if (menu_newval > work) {
menu_newval--;
settings.led_autothresh[menu_editing - SETTING_BRITE_THRESH0] = menu_newval;
do_beep = settings.beeper;
}
break;
}
case SENSOR_TEMP_CALVALUE: {
if (temperature_cal > -20) {
temperature_cal--;
do_beep = settings.beeper;
}
break;
}
}
if (do_beep) {
beep(settings.beep_type[0], 10);
}
}
void menu_edit_menu()
{
// values in this switch need to REVERT previous settings
switch (menu_editing) {
case SETTING_NAME: {
break;
}
case SETTING_CONTRAST: {
lcd_set_contrast(menu_oldval);
break;
}
case SETTING_FAVCOLOR_RED:
case SETTING_FAVCOLOR_GREEN:
case SETTING_FAVCOLOR_BLUE: {
settings.fav_color[menu_editing - SETTING_FAVCOLOR_RED] = menu_oldval;
break;
}
case SETTING_BEEP_TYPE_BUTTON:
case SETTING_BEEP_TYPE_PAGING:
case SETTING_BEEP_TYPE_ALARM: {
settings.beep_type[menu_editing - SETTING_BEEP_TYPE_BUTTON] = menu_oldval;
break;
}
case SENSOR_LIGHT_SETTINGSGAIN: {
settings.light_setgain = menu_oldval;
break;
}
case SETTING_BRITE_LCD_VALUE: {
settings.lcd_brightness = menu_oldval;
break;
}
case SETTING_BRITE_AUTOGAIN_LO: {
settings.led_autogain_lev_min = menu_oldval;
break;
}
case SETTING_BRITE_AUTOGAIN_HI: {
settings.led_autogain_lev_max = menu_oldval;
break;
}
case SETTING_BRITE_THRESH0:
case SETTING_BRITE_THRESH1:
case SETTING_BRITE_THRESH2:
case SETTING_BRITE_THRESH3:
case SETTING_BRITE_THRESH4: {
settings.led_autothresh[menu_editing - SETTING_BRITE_THRESH0] = menu_oldval;
break;
}
case SENSOR_TEMP_CALVALUE: {
temperature_cal = 0;
break;
}
}
// stop editing and return to menu control
menu_editing = 0;
menu_btntype_menus();
if (settings.beeper) {
beep(settings.beep_type[0], 10);
}
}
void menu_edit_ok()
{
// values in this switch need to COMMIT edited settings
switch (menu_editing) {
case SENSOR_TEMP_CALVALUE: {
I2C_WriteTransfer(ATTINY_I2C_ADDR, (uint8_t *)&temperature_cal, 1, ATTINY_CMD_TEMP_CAL, 1);
temperature_cal = 0;
break;
}
default: {break;}
}
// stop editing and return to menu control
menu_editing = 0;
menu_btntype_menus();
if (settings.beeper) {
beep(settings.beep_type[0] + 1, 10);
}
}
void menu_edit_start(uint16_t id)
{
menu_editing = id;
// set edited value
switch (id) {
case SETTING_CONTRAST: {
menu_oldval = menu_newval = settings.contrast;
break;
}
case SETTING_FAVCOLOR_RED:
case SETTING_FAVCOLOR_GREEN:
case SETTING_FAVCOLOR_BLUE: {
menu_newval = menu_oldval = settings.fav_color[menu_editing - SETTING_FAVCOLOR_RED];
break;
}
case SETTING_BEEP_TYPE_BUTTON:
case SETTING_BEEP_TYPE_PAGING:
case SETTING_BEEP_TYPE_ALARM: {
menu_newval = menu_oldval = settings.beep_type[menu_editing - SETTING_BEEP_TYPE_BUTTON];
break;
}
case SENSOR_LIGHT_SETTINGSGAIN: {
menu_newval = menu_oldval = settings.light_setgain;
break;
}
case SETTING_BRITE_LCD_VALUE: {
menu_newval = menu_oldval = settings.lcd_brightness;
break;
}
case SETTING_BRITE_AUTOGAIN_LO: {
menu_newval = menu_oldval = settings.led_autogain_lev_min;
break;
}
case SETTING_BRITE_AUTOGAIN_HI: {
menu_newval = menu_oldval = settings.led_autogain_lev_max;
break;
}
case SETTING_BRITE_THRESH0:
case SETTING_BRITE_THRESH1:
case SETTING_BRITE_THRESH2:
case SETTING_BRITE_THRESH3:
case SETTING_BRITE_THRESH4: {
menu_newval = menu_oldval = settings.led_autothresh[menu_editing - SETTING_BRITE_THRESH0];
break;
}
case SENSOR_TEMP_CALVALUE: {
temperature_cal = 0;
break;
}
}
// set buttons to editing control
menu_btntype_editing();
}
/* menu fn pointer set functions */
void menu_btntype_menus()
{
menu_mode = MENU_MODE_NAVIGATING_MENUS;
lcd_btn_fn[BTN_UP] = menu_btn_prev;
lcd_btn_fn[BTN_MENU] = menu_btn_menu;
lcd_btn_fn[BTN_OK] = menu_btn_ok;
lcd_btn_fn[BTN_DOWN] = menu_btn_next;
lcd_set_cursor(LCD_LINE_1, LCD_CMD_NO_CURSOR_FLASH);
lcd_set_height(LCD_CMD_SINGLEHEIGHT);
}
void menu_btntype_run()
{
menu_mode = MENU_MODE_RUNNING_PROGRAM;
lcd_btn_fn[BTN_UP] = menu_infopirate_btn_prev;
lcd_btn_fn[BTN_MENU] = menu_btn_menu;
lcd_btn_fn[BTN_OK] = menu_infopirate_btn_ok;
lcd_btn_fn[BTN_DOWN] = menu_infopirate_btn_next;
lcd_set_cursor(LCD_LINE_1, LCD_CMD_NO_CURSOR_FLASH);
lcd_set_height(LCD_CMD_DOUBLEHEIGHT);
}
void menu_btntype_editing()
{
menu_mode = MENU_MODE_EDITING;
lcd_btn_fn[BTN_UP] = menu_edit_prev;
lcd_btn_fn[BTN_MENU] = menu_edit_menu;
lcd_btn_fn[BTN_OK] = menu_edit_ok;
lcd_btn_fn[BTN_DOWN] = menu_edit_next;
lcd_set_cursor(LCD_LINE_2 + 7, LCD_CMD_CURSOR_FLASH);
}
// run mode
void menu_root_run(uint16_t id)
{
prog_init();
infopirate_init();
menu_btntype_run();
}
/* menu construction */
// root menu
const MenuData menu_rdata[9] = {
{"Run!", NULL, 0, 0, 0, 0, 0, menu_root_run, 0},
{"Radio", NULL, 0, 0, 0, 0, 0, NULL, 0},
{"Settings", NULL, 0, 0, 0, 0, 0, NULL, 0},
{"Programs", NULL, 0, 0, 0, 0, 0, NULL, 0},
{"Save", NULL, 0, 0, 0, 0, 0, menu_settings_save, 0},
{"Sensors", NULL, 0, 0, 0, 0, 0, NULL, 0},
{"Testing", NULL, 0, 0, 0, 0, 0, NULL, 0},
{"Credits", NULL, 0, 0, 0, 0, 0, NULL, 0},
{"Shutdown", NULL, 0, 0, 0, 0, 0, pirate_shutdown, 0}
};
const MenuItem menu_ritem[9] = {
{0, 0, &menu_ritem[1], &menu_runitem, &menu_rdata[0]},
{0, &menu_ritem[0], &menu_ritem[2], &menu_comm_ritem[0], &menu_rdata[1]},
{0, &menu_ritem[1], &menu_ritem[3], &menu_pref_ritem[0], &menu_rdata[2]},
{0, &menu_ritem[2], &menu_ritem[4], &menu_prog_ritem[0], &menu_rdata[3]},
{0, &menu_ritem[3], &menu_ritem[5], 0, &menu_rdata[4]},
{0, &menu_ritem[4], &menu_ritem[6], &menu_sens_ritem[0], &menu_rdata[5]},
{0, &menu_ritem[5], &menu_ritem[7], &menu_test_ritem[0], &menu_rdata[6]},
{0, &menu_ritem[6], &menu_ritem[8], &menu_cred_ritem[0], &menu_rdata[7]},
{0, &menu_ritem[7], 0, 0, &menu_rdata[8]},
};
// run entry
const MenuData menu_rundata = {"", NULL, 0, 4, 0, 0, 0, NULL, 0};
const MenuItem menu_runitem = {&menu_ritem[0], 0, 0, 0, &menu_rundata};

View File

@ -0,0 +1,106 @@
/**
* lcd_menu.c: lcd menuing prototypes
* 2014 by true
*
* ----
*
* $Id: lcd_menu.h 374 2015-06-29 02:06:22Z true $
*
**/
#ifndef __PIRATE_LCD_MENU_H
#define __PIRATE_LCD_MENU_H
#include <string.h>
#define LCD_ROOT_TEXT "WP DC22 and DC23 Badge v0.3d by true"
#define LCD_DEF_SPACING 4
#define LCD_DEF_SCROLL_WAIT 144
#define LCD_DEF_SCROLL_RUN 16
#define LCD_MENU_ROOT_COMMS 1
#define LCD_MENU_ROOT_SETTINGS 2
#define LCD_MENU_ROOT_PROGRAMS 3
#define LCD_MENU_ROOT_SENSORS 5
#define LCD_MENU_ROOT_TESTING 6
#define LCD_MENU_ROOT_CREDITS 7
#define BTN_UP 0
#define BTN_MENU 1
#define BTN_OK 2
#define BTN_DOWN 3
#define MENU_MODE_NAVIGATING_MENUS 0
#define MENU_MODE_EDITING 1
#define MENU_MODE_RUNNING_PROGRAM 2
#define MENU_MODE_PROGRAM_EDITOR 3
/* struct */
typedef struct MenuData {
char *disp; // string to display
char * (*dispfn)(uint16_t id); // function which returns string to display
uint16_t disp_id; // index to pass to dispfn
uint8_t dispfn_delay; // how many 5000hz ticks to wait before re-calling dispfn
uint8_t scroll_spaces; // how many spaces between scroll; 0 disables scroll
uint8_t scroll_time_wait; // how long to wait before (re)scrolling
uint8_t scroll_time_run; // how long to wait between characters
void (*entryfn)(uint16_t eid); // function to call when entering menu
uint16_t entry_id; // index to pass to entryfn
} MenuData;
typedef struct MenuItem MenuItem;
struct MenuItem {
const MenuItem *root;
const MenuItem *prev;
const MenuItem *next;
const MenuItem *enter;
const MenuData *this;
};
/* lcd variables */
extern MenuItem *menuc;
extern const MenuItem menu_ritem[9];
extern void (*lcd_btn_fn[4])();
/* menu variables */
extern uint8_t menu_mode;
extern uint16_t menu_editing;
extern uint32_t menu_oldval;
extern uint32_t menu_newval;
/* menu constants */
extern const MenuItem menu_runitem;
/* prototypes */
void lcd_menu_init();
void lcd_menu_set(const MenuItem *set);
void lcd_menu_update();
void lcd_menu_linescroll_reset(uint8_t idx);
void menu_edit_start(uint16_t id);
void menu_root_run(uint16_t id);
void menu_btn_next();
void menu_btn_prev();
void menu_btn_menu();
void menu_btn_ok();
void menu_btntype_menus();
void menu_btntype_run();
void menu_btntype_editing();
#endif

View File

@ -0,0 +1,43 @@
/**
* menu_credits.c: we are legit
* 2014 by true
*
* ----
*
* $Id: menu_credits.c 350 2015-05-28 02:23:03Z true $
*
**/
#include <pirate.h>
#include "lcd_menu.h"
#include "menu_credits.h"
/* menu construction */
const MenuData menu_cred_rdata[] = {
{"idea by rCON and true (at the last minute)", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"T3K shipmates Bad Kobold and the lord canon", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"a fire? don't blame us if you didn't know", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"financed by captain rCON's billions", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"code and design rushed by true", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"the lord canon's divorce", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"keep it between the bones, guys", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"is your badge shit? did it break? blame BK", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"always need moar cake from avah", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"do what you want 'cause a pirate is free", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT - 40, LCD_DEF_SCROLL_RUN - 4, NULL, 0},
{"you are A PIRATE", NULL, 0, 0, 3, LCD_DEF_SCROLL_WAIT, LCD_DEF_SCROLL_RUN + 2, NULL, 0}
};
const MenuItem menu_cred_ritem[] = {
{&menu_ritem[LCD_MENU_ROOT_CREDITS], 0, &menu_cred_ritem[1], 0, &menu_cred_rdata[0]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[0], &menu_cred_ritem[2], 0, &menu_cred_rdata[1]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[1], &menu_cred_ritem[3], 0, &menu_cred_rdata[2]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[2], &menu_cred_ritem[4], 0, &menu_cred_rdata[3]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[3], &menu_cred_ritem[5], 0, &menu_cred_rdata[4]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[4], &menu_cred_ritem[6], 0, &menu_cred_rdata[5]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[5], &menu_cred_ritem[7], 0, &menu_cred_rdata[6]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[6], &menu_cred_ritem[7], 0, &menu_cred_rdata[7]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[7], &menu_cred_ritem[8], 0, &menu_cred_rdata[8]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[8], &menu_cred_ritem[10], 0, &menu_cred_rdata[9]},
{&menu_ritem[LCD_MENU_ROOT_CREDITS], &menu_cred_ritem[9], 0, 0, &menu_cred_rdata[10]}
};

Some files were not shown because too many files have changed in this diff Show More