Skip to content

Commit

Permalink
Recalibrated timings for 16Mz clock. Added docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
evenwestvang committed Mar 7, 2013
1 parent 2af03ec commit d7d7d9e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.git
*.o
*.elf
*.d
*.d
*.hex
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -B 10 -F
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -I. -ffunction-sections --std=c99

# symbolic targets:
all: chord.hex
all: reverse.hex

.c.o:
$(COMPILE) -c $< -o $@
Expand All @@ -60,7 +60,7 @@ all: chord.hex
$(COMPILE) -S $< -o $@

flash: all
$(AVRDUDE) -U flash:w:chord.hex:i
$(AVRDUDE) -U flash:w:reverse.hex:i

fuse:
$(AVRDUDE) $(FUSES)
Expand All @@ -70,18 +70,18 @@ install: flash fuse

# if you use a bootloader, change the command below appropriately:
load: all
bootloadHID chord.hex
bootloadHID reverse.hex

clean:
rm -f chord.hex main.elf $(OBJECTS) $(OBJECTS:.o=.d)
rm -f reverse.hex main.elf $(OBJECTS) $(OBJECTS:.o=.d)

# file targets:
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS) -lm -Wl,--gc-sections

chord.hex: main.elf
rm -f chord.hex
avr-objcopy -j .text -j .data -O ihex main.elf chord.hex
reverse.hex: main.elf
rm -f reverse.hex
avr-objcopy -j .text -j .data -O ihex main.elf reverse.hex
avr-size -C --mcu=$(DEVICE) main.elf
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
A quick rebuild of David Carne's *Reverse Engineering the iPod Shuffle 3G headphone remote protocol* from http://david.carne.ca/shuffle_hax/shuffle_remote.html for the stock Arduino Atmega 328 clocked to 16Mhz
# Reverse shuffle

A quick recalibration of David Carne's *Reverse Engineering the iPod Shuffle 3G headphone remote protocol* from http://david.carne.ca/shuffle_hax/shuffle_remote.html for the stock Arduino Atmega 328 clocked to 16Mhz.

## To compile and write

* Get avrdude and avr-gcc
* Attach AVR-ISP to ISP-port
* Compile with 'make'
* Flash with 'make flash'
* Signal appears on PIN5 on the Arduino (PortB, pin 5)

If avrdude can't find your programmer try editing the makefile l.33

PROGRAMMER ?= -c avrisp2 -P usb

to point to where the programmer actually show up, /dev/something, instead of just usb.

WIP
19 changes: 15 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@
#define CTL_PIN (1<<5)
#define CTL_HI (!(ACSR & (1<<ACO)))

#define BLINK_DELAY_MS 100


void main()
{

// Flash LED once for debug
DDRB |= _BV(DDB5);
PORTB |= _BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);

PORTB &= ~_BV(PORTB5);


CLKPR = 0x80;
CLKPR = 0x0;
ADCSRB &= ~(1<< ACME);
Expand All @@ -25,15 +36,15 @@ void main()
PORTC |= CTL_PIN;
_delay_ms(4.2);

// 280khz burst
// 280khz burst (scoped at 277khz)
TCCR0A = 0x23;
TCNT0 = 0x0;
OCR0A = 27;
OCR0A = 56;
DDRD |= 1<<5;
_delay_ms(1.5);

// 245khz burst
OCR0A = 33;
// 245khz burst (scope at 247khz)
OCR0A = 63;
TCNT0 = 0x0;
_delay_ms(4.6);

Expand Down

0 comments on commit d7d7d9e

Please sign in to comment.