; ; CPU Init module ; ; Initialize all MPU registers and return to calling routine ; ; Trashes R1 ; ; Assumes the various .SET symbols have been updated with the ; appropriate bits needed to initialize the MPU ; cpu_init: ldi temp, PORTD_INIT ; set output state before direction. out PORTD, temp ; at reset output is low, direction is in. ldi temp, DDRD_INIT out DDRD, temp ldi temp, PORTB_INIT ; ditto out PORTB, temp ldi temp, DDRB_INIT out DDRB, temp ldi temp, ACSR_INIT ; Analog Interrupt Mask out ACSR, temp ldi temp, TCNT0_INIT out TCNT0, temp ldi temp, TCCR0_INIT out TCCR0, temp ldi temp, TIFR_INIT out TIFR, temp ldi temp, TIMSK_INIT ; yeah, this is just a bit set... out TIMSK, temp ldi temp, MCUCR_INIT ; set up sleep mode & Extn interrupt out MCUCR, temp ldi temp, WDTCR_INIT out WDTCR, temp ldi temp, GIMSK_INIT ; External Interrupt mask out GIMSK, temp ldi temp, SREG_INIT out SREG, temp ; enable interrupts ret