Last active
October 26, 2020 05:48
-
-
Save sago35/d8d039e4037b3d7fd2e3c19ad797897f to your computer and use it in GitHub Desktop.
(machine.SPI).txrx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) disassemble | |
Dump of assembler code for function (machine.SPI).txrx: | |
0x00005b82 <+0>: stmdb sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr} | |
0x00005b86 <+4>: sub sp, #12 | |
=> 0x00005b88 <+6>: cmp r0, #0 | |
0x00005b8a <+8>: str r3, [sp, #8] | |
0x00005b8c <+10>: beq.n 0x5c24 <(machine.SPI).txrx+162> | |
0x00005b8e <+12>: mov r11, r2 | |
0x00005b90 <+14>: cmp r2, #0 | |
0x00005b92 <+16>: beq.n 0x5c20 <(machine.SPI).txrx+158> | |
0x00005b94 <+18>: mov r9, r1 | |
0x00005b96 <+20>: add.w r5, r0, #40 ; 0x28 | |
0x00005b9a <+24>: ldrb r1, [r1, #0] | |
0x00005b9c <+26>: str r0, [sp, #4] | |
0x00005b9e <+28>: mov r0, r5 | |
0x00005ba0 <+30>: ldr r7, [sp, #48] ; 0x30 | |
0x00005ba2 <+32>: bl 0xecfe <(*runtime/volatile.Register32).Set> | |
0x00005ba6 <+36>: cmp r7, #2 | |
0x00005ba8 <+38>: blt.n 0x5bf8 <(machine.SPI).txrx+118> | |
0x00005baa <+40>: ldr r0, [sp, #4] | |
0x00005bac <+42>: adds r6, r7, #1 | |
0x00005bae <+44>: mov.w r8, #1 | |
0x00005bb2 <+48>: add.w r4, r0, #24 | |
0x00005bb6 <+52>: mov r0, r4 | |
0x00005bb8 <+54>: movs r1, #1 | |
0x00005bba <+56>: bl 0xede8 <(*runtime/volatile.Register8).HasBits> | |
0x00005bbe <+60>: lsls r0, r0, #31 | |
0x00005bc0 <+62>: beq.n 0x5bb6 <(machine.SPI).txrx+52> | |
0x00005bc2 <+64>: cmp r8, r11 | |
0x00005bc4 <+66>: beq.n 0x5c20 <(machine.SPI).txrx+158> | |
0x00005bc6 <+68>: ldrb.w r1, [r9, r8] | |
0x00005bca <+72>: mov r0, r5 | |
0x00005bcc <+74>: bl 0xecfe <(*runtime/volatile.Register32).Set> | |
0x00005bd0 <+78>: mov r0, r4 | |
0x00005bd2 <+80>: movs r1, #4 | |
0x00005bd4 <+82>: bl 0xede8 <(*runtime/volatile.Register8).HasBits> | |
0x00005bd8 <+86>: lsls r0, r0, #31 | |
0x00005bda <+88>: beq.n 0x5bd0 <(machine.SPI).txrx+78> | |
0x00005bdc <+90>: cmp r8, r6 | |
0x00005bde <+92>: beq.n 0x5c20 <(machine.SPI).txrx+158> | |
0x00005be0 <+94>: ldr r0, [sp, #8] | |
0x00005be2 <+96>: add.w r10, r8, r0 | |
0x00005be6 <+100>: mov r0, r5 | |
0x00005be8 <+102>: bl 0xecb4 <(*runtime/volatile.Register32).Get> | |
0x00005bec <+106>: add.w r8, r8, #1 | |
0x00005bf0 <+110>: strb.w r0, [r10, #-1] | |
0x00005bf4 <+114>: cmp r8, r7 | |
0x00005bf6 <+116>: bne.n 0x5bb6 <(machine.SPI).txrx+52> | |
0x00005bf8 <+118>: ldr r0, [sp, #4] | |
0x00005bfa <+120>: add.w r4, r0, #24 | |
0x00005bfe <+124>: mov r0, r4 | |
0x00005c00 <+126>: movs r1, #4 | |
0x00005c02 <+128>: bl 0xede8 <(*runtime/volatile.Register8).HasBits> | |
0x00005c06 <+132>: lsls r0, r0, #31 | |
0x00005c08 <+134>: beq.n 0x5bfe <(machine.SPI).txrx+124> | |
0x00005c0a <+136>: cbz r7, 0x5c20 <(machine.SPI).txrx+158> | |
0x00005c0c <+138>: ldr r0, [sp, #8] | |
0x00005c0e <+140>: adds r4, r7, r0 | |
0x00005c10 <+142>: mov r0, r5 | |
0x00005c12 <+144>: bl 0xecb4 <(*runtime/volatile.Register32).Get> | |
0x00005c16 <+148>: strb.w r0, [r4, #-1] | |
0x00005c1a <+152>: add sp, #12 | |
0x00005c1c <+154>: ldmia.w sp!, {r4, r5, r6, r7, r8, r9, r10, r11, pc} | |
0x00005c20 <+158>: bl 0x7696 <runtime.lookupPanic> | |
0x00005c24 <+162>: bl 0x7768 <runtime.nilPanic> | |
End of assembler dump. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (spi SPI) txrx(tx, rx []byte) { | |
spi.Bus.DATA.Set(uint32(tx[0])) | |
for i := 1; i < len(rx); i++ { | |
for !spi.Bus.INTFLAG.HasBits(sam.SERCOM_SPIM_INTFLAG_DRE) { | |
} | |
spi.Bus.DATA.Set(uint32(tx[i])) | |
for !spi.Bus.INTFLAG.HasBits(sam.SERCOM_SPIM_INTFLAG_RXC) { | |
} | |
rx[i-1] = byte(spi.Bus.DATA.Get()) | |
} | |
for !spi.Bus.INTFLAG.HasBits(sam.SERCOM_SPIM_INTFLAG_RXC) { | |
} | |
rx[len(rx)-1] = byte(spi.Bus.DATA.Get()) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) disassemble | |
Dump of assembler code for function (*runtime/volatile.Register8).Get: | |
0x0000ed1e <+0>: push {r7, lr} | |
=> 0x0000ed20 <+2>: cmp r0, #0 | |
0x0000ed22 <+4>: itt ne | |
0x0000ed24 <+6>: ldrbne r0, [r0, #0] | |
0x0000ed26 <+8>: popne {r7, pc} | |
0x0000ed28 <+10>: bl 0x7768 <runtime.nilPanic> | |
End of assembler dump. | |
// Get returns the value in the register. It is the volatile equivalent of: | |
// | |
// *r.Reg | |
// | |
//go:inline | |
func (r *Register8) Get() uint8 { | |
return LoadUint8(&r.Reg) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) disassemble | |
Dump of assembler code for function (*runtime/volatile.Register8).HasBits: | |
0x0000ede8 <+0>: push {r4, lr} | |
0x0000edea <+2>: mov r4, r1 | |
=> 0x0000edec <+4>: bl 0xed1e <(*runtime/volatile.Register8).Get> | |
0x0000edf0 <+8>: ands r0, r4 | |
0x0000edf2 <+10>: uxtb r0, r0 | |
0x0000edf4 <+12>: cmp r0, #0 | |
0x0000edf6 <+14>: it ne | |
0x0000edf8 <+16>: movne r0, #1 | |
0x0000edfa <+18>: pop {r4, pc} | |
End of assembler dump. | |
// HasBits reads the register and then checks to see if the passed bits are set. It | |
// is the volatile equivalent of: | |
// | |
// (*r.Reg & value) > 0 | |
// | |
//go:inline | |
func (r *Register8) HasBits(value uint8) bool { | |
return (r.Get() & value) > 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment