-
-; POWER SAVING MODE
-;
-; To reduce physical size, we won't use a latching power switch. Instead,
-; playback will stop after a full iteration (16m23s). Then, a momentary
-; button will trigger a RESET, INT0 or PCINT0 interrupt to resume
-; playback. Meanwhile, all periphials will be shut down and the clock
-; turned off. The watchdog is permanently off to reduce power consumption.
-; Note: it is not necessary to switch the clock source from the 8MHz
-; oscillator to the 128kHz one, since power-down mode disables the clock
-; completely.
-
-; TODO: if we are using pcint on the audio-out pin, we could instruct the user to short the audio plug to ground to start playback (which should be triggered by a connected audio source). this would eliminate the button (and associated wiring) completely.
-
-halt:
- ;set all pins as input & enable pullups and disable periphials to conserve energy
- LDI x, 0x00
- OUT DDRB, x
- LDI x, 0x0f
- OUT PUEB, x
- LDI x, 0x3 ; bit0: disable Timer0, bit1: disable attiny5/10's ADC
- OUT PRR, x
-
- SBI PCMSK, 0 ; enable PCINT0 on PB0 (pin1; also audio out)
- SBI PCICR, 0 ; enable PCINT0
-
- ;enter power-down-mode
- LDI x, 0x05 ; power-down mode:____010_ ; enable:_______1
- OUT SMCR, x
- CLR x
- SLEEP
- OUT SMCR, x
-
- RJMP continue
-
-
-pcint_handler:
- SBI PCIFR, 0 ; clear interrupt
- LDI x, 0x05
- OUT DDRB, x
- LDI x, 0x00
- OUT PUEB, x
- LDI x, 0x02
- OUT PRR, x ; reset prr (not using zero, so devices with adc keep it disabled)
- ; TODO: should probably reset i0/i1/i2
- RETI
-
-; XXX: 14 byte too large; should probably purge i3, rerun fakeasm-tests with length reduced to 7864320. a dedicated five-register will save 2 instructions, too.