Skip to content

The capture contest entry from David Fries #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 77 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e438719
add missing include dependency
dfries Dec 27, 2012
d3c5e90
ignore the cpu_clock executable
dfries Dec 27, 2012
73a5f92
switch to C++ for the advantages of that language
dfries Dec 27, 2012
b4ba7e0
add return to main
dfries Dec 28, 2012
0fefcf0
Give the Hz to hz_is_not_valid, unused here.
dfries Dec 28, 2012
8341485
start from hrt_example.c
dfries Jan 14, 2013
ea9ccf3
initial gutting, sets up the timers and sets the LEDs then returns
dfries Jan 15, 2013
de985cc
fixes and hardware input output checkout test
dfries Jan 15, 2013
39b52ed
fix TCCR1B assignment, the 2nd write overrode the 1st
dfries Jan 15, 2013
f31fd23
comment out attempt at a random number seed
dfries Jan 15, 2013
8895ba9
EEMEM isn't working, use PROGMEM instead
dfries Jan 15, 2013
4e6d701
code cleanup now that it was tested to work on the keypad hardware
dfries Jan 15, 2013
f6fe072
the game, pretty functional
dfries Jan 15, 2013
a403209
Contest entry by David Fries, titled "capture"
dfries Jan 15, 2013
3bbf4b4
consistent score display speed and update rates
dfries Jan 27, 2013
a255149
fix new high score routine
dfries Jan 27, 2013
248275e
bug fix, getting a high score gets wraps turns around, fix score repeat
dfries Jan 28, 2013
55f0a4c
distinguish between the high score and current score
dfries Jan 28, 2013
2836979
use the time to the first button press for the random number seed
dfries Jan 28, 2013
6a15fc2
Play a tone and keep the captured LED lit for a bit.
dfries Jan 28, 2013
f783f94
use the 10's led to display scores in the 100's
dfries Jan 29, 2013
7928ed7
start the successful capture at a higher pitch
dfries Jan 29, 2013
d9379a0
add Capture gameplay notes
dfries Jan 29, 2013
54b8004
start on a software stand in for the Hall Research KP2B keypad
dfries Dec 27, 2012
12b18e4
Split into two rows like the hardware.
dfries Dec 27, 2012
e15970f
put the full GPL copyright at the top
dfries Dec 27, 2012
de687ae
initial start on ATtiny source code compatibility
dfries Dec 27, 2012
cabc92b
iotn2313.h from Debian avr-libc 1:1.8.0-2
dfries Dec 28, 2012
6000975
disable the register access macros
dfries Dec 28, 2012
eca4393
compiling, but not at all hooked up
dfries Dec 28, 2012
e659bc5
avr_lib's argument is a double, matching, fixed a bug
dfries Dec 28, 2012
5f1b618
Run the microcontroller main function, no io hooked up yet.
dfries Dec 28, 2012
79ab844
This should have most major classes available.
dfries Dec 29, 2012
eedf884
Use C++11 lambda to define the different set operations
dfries Dec 29, 2012
356f7ae
register uint16_t for a signal argument type
dfries Dec 29, 2012
1efeb18
allow forwarding the output ports to the LED GUIs
dfries Dec 29, 2012
1b96d4c
Create LEDWidget for displaying the LED status.
dfries Dec 30, 2012
e7f5d51
Mask out any set bits that are set for input.
dfries Dec 30, 2012
ead4aec
enable input buttons
dfries Dec 31, 2012
1db4495
Translate keyboard events into button states.
dfries Jan 11, 2013
ddb8d0e
add ^= register operator (used in the sound example)
dfries Jan 12, 2013
71bab35
add _delay_us
dfries Jan 12, 2013
e5983f9
emulate square wave audio to the sound card
dfries Jan 12, 2013
9019844
moved iotn2313.h to avr/iotn2313.h
dfries Jan 12, 2013
791e375
Add processor affinity.
dfries Jan 12, 2013
9fd338b
added Timer Counter 0, compiles but not finished
dfries Jan 13, 2013
302ee45
redo compiling the avr source, put the object code in this directory
dfries Jan 13, 2013
76a0cd2
Expanding the includes to support interrupts.
dfries Jan 14, 2013
59170bb
bug fix, bit number and NULL check
dfries Jan 14, 2013
9e36331
dummy sei() function
dfries Jan 14, 2013
a4efcd0
add 16 bit read/write required for Timer1
dfries Jan 14, 2013
bf2eb75
fixes to get interrupts to work from Timer0
dfries Jan 14, 2013
04bf67f
get Timer1 to work and related fixups
dfries Jan 14, 2013
071209d
Bug fix, CPU clock wasn't updating
dfries Jan 14, 2013
e60ae99
update the sleep value when the cpu clock changes
dfries Jan 14, 2013
4f40ffb
add util/atomic.h as a whole, enable register SREG
dfries Jan 15, 2013
36195b9
enable timer normal mode
dfries Jan 15, 2013
119006c
stub out cli for now
dfries Jan 15, 2013
f9aa5d3
switch avr program
dfries Jan 15, 2013
d4c74a5
Add interrupt enable, disable routines.
dfries Jan 15, 2013
b70ec1b
correct the button labels, the hardware is 1 based for labels
dfries Jan 15, 2013
f064ce5
add support for sleep, it seems to be eating up a lot of CPU
dfries Jan 15, 2013
5ca1785
display a checkmark when a key is pressing that button
dfries Jan 15, 2013
ba241d2
add += and -= for most register operations
dfries Jan 15, 2013
6766654
fill out program memory accessors required for now
dfries Jan 15, 2013
93ed144
const pointers for reading from eeprom
dfries Jan 15, 2013
efe9613
memcpy into top as the compiler was complaining about type punning
dfries Jan 15, 2013
0c90e71
initialize value in case it doesn't get written to
dfries Jan 15, 2013
286c464
Correct the initial button state.
dfries Jan 15, 2013
4fa40e2
fixup TCNT0 and TCNT1 register reads
dfries Jan 28, 2013
e5668ef
add ++ operator to registers
dfries Jan 29, 2013
6aeb57e
add libavr_target.so to the clean target
dfries Jan 29, 2013
b10da10
selecting capture.cc as the source program
dfries Jan 29, 2013
a4ac552
clock_div_t and clock_prescale_set to set the clock speed
dfries Jan 29, 2013
a9ff091
stub out the watch dog timer
dfries Jan 29, 2013
4de6f0a
force compiling the target with C++ and update the path to samples
dfries Jan 29, 2013
38af80a
use the clock_div_1 instead of 0 (C++ complains), skip asm
dfries Jan 29, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
keypadContest
keypadContest.wiki
.*.swp
*.d
*.eep
*.hex
*.elf
*.elf.old
*.lss
*.lst
*.map
*.sym
*.o
.*.swp
moc_*.cc
moc_*.d
moc_*.o
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions include/ATtiny2313_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ SOFTWARE.
#ifndef ATtiny2313_clock_H
#define ATtiny2313_clock_H

#include <avr/io.h>

/* Clock prescaler, MHz, and change logic for the ATtiny2313 assuming the
* internal 8 MHz oscillator is selected for the clock source.
*/
Expand All @@ -45,7 +47,7 @@ SOFTWARE.

/* Leave this undefined to catch non-constant (invalid) input values.
*/
uint8_t hz_is_not_valid(void);
uint8_t hz_is_not_valid(uint32_t hz);
/* Takes the number of CPU cycles per second and returns the CPU prescaler
* CLKPR value. The hardware only supports 9 clock rates.
* returns the prescale CLKPR value
Expand All @@ -68,7 +70,7 @@ inline uint8_t inline_cpu_hz_to_prescale(uint32_t hz)
hz==125000 ? CPU_125kHz :
hz==62500 ? CPU_62500Hz :
hz==31250 ? CPU_31250Hz :
hz_is_not_valid();
hz_is_not_valid(hz);
}

// Add -DF_CPU=8000000 (or a valid Hz) to the compile command line, and
Expand Down
1 change: 1 addition & 0 deletions src/cpu_clock/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpu_clock
8 changes: 4 additions & 4 deletions src/cpu_clock/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
MCU=attiny2313
AVRDUDEMCU=attiny2313
CC=avr-gcc
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=$(MCU) -std=gnu99
CXX=avr-g++
CXXFLAGS=-g -Os -Wall -mcall-prologues -mmcu=$(MCU) -std=c++11
ELF2HEX=avr-objcopy
OBJDUMP=avr-objdump
AVRDUDE=avrdude
TARGET=cpu_clock
SIZE=avr-size

CFLAGS:=$(CFLAGS) -DF_CPU=8000000
CXXFLAGS:=$(CXXFLAGS) -DF_CPU=8000000

# always build
.PHONY: all program
Expand All @@ -19,7 +19,7 @@ program : $(TARGET).hex
$(AVRDUDE) -p $(AVRDUDEMCU) -c usbtiny -U flash:w:$(TARGET).hex

%.elf : %.o
$(CC) $(CFLAGS) $< -o $@
$(CXX) $(CXXFLAGS) $< -o $@

%.hex : %.elf
$(ELF2HEX) -R .eeprom -O ihex $< $@
Expand Down
1 change: 1 addition & 0 deletions src/cpu_clock/cpu_clock.c → src/cpu_clock/cpu_clock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,5 @@ int main(void)
if(leds >= 1<<10)
leds=1;
}
return 1;
}
52 changes: 52 additions & 0 deletions src/dfries_capture/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
MCU=attiny2313
AVRDUDEMCU=attiny2313
CXX=avr-g++
CXXFLAGS=-g -Os -Wall -mcall-prologues -mmcu=$(MCU) -std=c++11
ELF2HEX=avr-objcopy
OBJDUMP=avr-objdump
AVRDUDE=avrdude
TARGET=capture
SIZE=avr-size

CXXFLAGS:=$(CXXFLAGS) -DF_CPU=8000000

# always build
.PHONY: all program

all: sizebefore $(TARGET).hex $(TARGET).lss sizeafter program

program : $(TARGET).hex
$(AVRDUDE) -p $(AVRDUDEMCU) -c usbtiny -U flash:w:$(TARGET).hex

%.elf : %.o
$(CXX) $(CXXFLAGS) $< -o $@

%.hex : %.elf
$(ELF2HEX) -R .eeprom -O ihex $< $@

# Prints the previous and current executable sizes, useful to keep track of
# the program growth.
# text: program code and flash allocate data
# data: constants used to initialize static variables, takes flash and ram
# bss: static variables not assigned constants, ram only
# dec: total in decimal
# hex: total in hex
sizebefore:
@cp $(TARGET).elf $(TARGET).elf.old 2> /dev/null || true

sizeafter: $(TARGET).elf
@if test -f $(TARGET).elf; then \
if test -f $(TARGET).elf.old; then \
echo Size before:; $(SIZE) $(TARGET).elf.old; fi; \
if cmp --quiet $(TARGET).elf.old $(TARGET).elf; then \
echo Size after: file is identical; else \
echo Size after:; $(SIZE) $(TARGET).elf; \
fi 2>/dev/null; fi

# extended assembly listing file
%.lss: %.elf
$(OBJDUMP) -h -S -z $< > $@

clean :
rm -f *.hex *.elf *.elf.old *.lss *.o *.d

Loading