Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- asm volatile(
- "ldi r16,1\n\t"
- "mov __tmp_reg__,r16\n\t"
- "clr __zero_reg__\n\t"
- "clr r22\n\t"
- "clr r23\n\t"
- "clr r24\n\t"
- "clr r25\n\t"
- "ldi r16, 0xff\n\t"
- // wait for datablock start (0xfe)
- "waitForDBStart:\n\t"
- "in r17, 0x2d\n\t"
- "in r17, 0x2e\n\t"
- "out 0x2e, r16\n\t"
- "waitForDBStartResponse:\n\t"
- "in r17, 0x2d\n\t"
- "sbrs r17, 7\n\t"
- "rjmp waitForDBStartResponse\n\t"
- "in r17, 0x2e\n\t"
- "cpi r17, 0xfe\n\t"
- "brne waitForDBStart\n\t"
- "clr r20\n\t"
- "clr r21\n\t"
- // initiate first SPI transfer of data block
- "out 0x2e, r16\n\t"
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "nop\n\t" // wait for the first byte to come through
- "SPItoScreenLoop:\n\t"
- // Read last byte from SPI
- "in r17, 0x2e\n\t"
- // initiate next SPI transfer while we output to screen
- "out 0x2e, r16\n\t"
- // low nibble to PORTF high
- "mov r19, r17\n\t"
- "lsl r19\n\t"
- "lsl r19\n\t"
- "lsl r19\n\t"
- "lsl r19\n\t"
- "out 0x11, r19\n\t"
- // high nibble to PORTD low
- "in r18, 0x0b\n\t"
- "andi r18, 0xf0\n\t"
- "lsr r17\n\t"
- "lsr r17\n\t"
- "lsr r17\n\t"
- "lsr r17\n\t"
- "or r18, r17\n\t"
- "out 0x0b, r18\n\t"
- // Toggle ILI WR
- "cbi 0x08, 6\n\t"
- "sbi 0x08, 6\n\t"
- // Check if we are done
- "add r20, __tmp_reg__\n\t"
- "adc r21, __zero_reg__\n\t"
- "cpi r21,2\n\t" // test against 512
- "brne jmpToStart\n\t"
- "cpi r20,0\n\t" // test against 513 as we skip the first write to let us write to screen while waiting for SPI
- "brne jmpToStart\n\t"
- "rjmp readCRC\n\t"
- "jmpToStart:\n\t"
- "rjmp SPItoScreenLoop\n\t"
- "readCRC:\n\t"
- "in r17, 0x2d\n\t"
- "in r17, 0x2e\n\t"
- "out 0x2e, r16\n\t"
- "readCRCResponse:\n\t"
- "in r17, 0x2d\n\t"
- "sbrs r17, 7\n\t"
- "rjmp readCRCResponse\n\t"
- "checkLoop:\n\t"
- "add r22, __tmp_reg__\n\t"
- "adc r23, __zero_reg__\n\t"
- "adc r24, __zero_reg__\n\t"
- "adc r25, __zero_reg__\n\t"
- "cpi r22, 0xd6\n\t"
- "brne jumpToDBStart\n\t"
- "cpi r23, 0x07\n\t"
- "brne jumpToDBStart\n\t"
- "cpi r24, 0x04\n\t"
- "brne jumpToDBStart\n\t"
- "cpi r25, 0x00\n\t"
- "brne jumpToDBStart\n\t"
- "rjmp end\n\t"
- "jumpToDBStart:\n\t"
- "rjmp waitForDBStart\n\t"
- "end:\n\t"
- :
- :
- : "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25"
- );
Advertisement
Add Comment
Please, Sign In to add comment