Skip to content

Instantly share code, notes, and snippets.

@blondie7575
Created February 15, 2013 03:36
Show Gist options
  • Save blondie7575/4958409 to your computer and use it in GitHub Desktop.
Save blondie7575/4958409 to your computer and use it in GitHub Desktop.
/////////////////
// CPU Interrupt Service Routine
//
INT2_vect:
// Save registers
push accum
in accum,SREG
push accum
in accum,PORTD
push accum
in accum,DDRD
push accum
push XL
push XH
// Enable the CPU's bus access
cbi PORTB,cpuBusAllow
// Read the data from the CPU
ldi accum,0x00
out DDRD,accum
ldi accum,0xff
out PORTD,accum
nop
in accum,PIND
// Enqueue to command buffer
lds XL,CMDBUFFER_E
ldi XH,CMDBUFFER_H
st X,accum
inc XL
sts CMDBUFFER_E,XL
// Disable the CPU's bus access
sbi PORTB,cpuBusAllow
// Restore registers
pop XH
pop XL
pop accum
out DDRD,accum
pop accum
out PORTD,accum
pop accum
out SREG,accum
pop accum
reti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment