__asm__(
".equ SYNC, (0x1UL << (7U)) \n\t"
".equ RPLY, (0x1UL << (1U)) \n\t"
".equ RE, (0x1UL << 0) \n\t"
".equ INVERT, 0xFFFF \n\t"
"movw r3,#0x7FF \n\t" //cycle 0 to 0x7FF step 1, number get data
"movw r4,#0x0 \n\t" //cycle 0 to 0xFF step 2, 2 byte get data (16-bit)
"movw r2,INVERT \n\t"
"start: \n\t"
//wait sync to hight
"sync_h: \n\t"
"ldr r1,[%[porta]] \n\t"
"tst r1,SYNC \n\t"
"beq sync_h \n\t"
//wait sync to low
"sync_l: \n\t"
"ldr r1,[%[porta]] \n\t"
"tst r1,SYNC \n\t"
"bne sync_l \n\t"
//save port C to mass
"ldrh r1,[%[portc]] \n\t"
"eor r1,r2 \n\t" //invert address
"strh r1,[%[mass],r4] \n\t" //save adress to mass
"add r4,#2 \n\r" //add shift to nember of mass
"sub r3,#1 \n\r" //increment number
"cmp r3,0x0 \n\r" //if end to mass goto end
"beq end \n\r"
//wait RE, if first Sync, then no data, then goto start
"re_sync_l: \n\t"
"ldr r1,[%[porta]] \n\t"
"tst r1,SYNC \n\t"
"bne start \n\t" //if SYNC is high then no data goto start
"tst r1,RE \n\t" //wait low RE
"bne re_sync_l \n\t"
//Wait RPLE
"rply_l: \n\t"
"ldr r1,[%[porta]] \n\t"
"tst r1,RPLY \n\t" //wait low RE
"bne rply_l \n\t"
//
"ldrh r1,[%[portc]] \n\t"
"eor r1,r2 \n\t" //invert data
"rev16 r1,r1 \n\t" //converts 16-bit big-endian data into little-endian data
"strh r1,[%[mass],r4] \n\t"
"add r4,#2 \n\r"
"sub r3,#1 \n\r"
"cmp r3,0x0 \n\r"
"bne start \n\r"
//"str r0,[%[mass]]\n\t"
//"strh r8,[%[porta]]\n\t"
//"str r9,[%[porta]]\n\t"
//"b start\n\t"
"end: \n\r"
:
:[mass]"r"(mass),[portc]"r"(portc),[porta]"r"(porta)
:"memory","r0","r1","r2","r3","r4"
);
[свернуть]