diff options
author | sago35 <[email protected]> | 2021-05-05 22:39:01 +0900 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-05-06 10:32:24 +0200 |
commit | 6f61b83ad5cea4f19b82d6721e3fbb165ac44fc1 (patch) | |
tree | 25da0cb9e1887811d9a7c651718dfeeeacdde25c /src/machine/machine_atsamd21.go | |
parent | 8dfefb46d10b3004d2f07d4e8976680ad9a79208 (diff) | |
download | tinygo-6f61b83ad5cea4f19b82d6721e3fbb165ac44fc1.tar.gz tinygo-6f61b83ad5cea4f19b82d6721e3fbb165ac44fc1.zip |
atsamd21: remove special handling for SPI-24mhz
Diffstat (limited to 'src/machine/machine_atsamd21.go')
-rw-r--r-- | src/machine/machine_atsamd21.go | 89 |
1 files changed, 12 insertions, 77 deletions
diff --git a/src/machine/machine_atsamd21.go b/src/machine/machine_atsamd21.go index 76d6c5d49..aca801c57 100644 --- a/src/machine/machine_atsamd21.go +++ b/src/machine/machine_atsamd21.go @@ -8,7 +8,6 @@ package machine import ( - "device" "device/arm" "device/sam" "errors" @@ -1301,43 +1300,21 @@ var ( // spi.Tx(nil, rx) // func (spi SPI) Tx(w, r []byte) error { - if spi.Bus.BAUD.Get() == 0x00 { - // When the SPI Freq is 24MHz, special processing is performed to improve the speed. + switch { + case w == nil: + // read only, so write zero and read a result. + spi.rx(r) + case r == nil: + // write only + spi.tx(w) - switch { - case w == nil: - // read only, so write zero and read a result. - spi.rx(r) - case r == nil: - // write only - spi.tx24mhz(w) - - default: - // write/read - if len(w) != len(r) { - return ErrTxInvalidSliceSize - } - - spi.txrx24mhz(w, r) + default: + // write/read + if len(w) != len(r) { + return ErrTxInvalidSliceSize } - } else { - switch { - case w == nil: - // read only, so write zero and read a result. - spi.rx(r) - case r == nil: - // write only - spi.tx(w) - - default: - // write/read - if len(w) != len(r) { - return ErrTxInvalidSliceSize - } - - spi.txrx(w, r) - } + spi.txrx(w, r) } return nil @@ -1390,48 +1367,6 @@ func (spi SPI) txrx(tx, rx []byte) { rx[len(rx)-1] = byte(spi.Bus.DATA.Get()) } -// tx24mhz is a special tx/rx function for CPU Clock 48 Mhz and SPI Freq 24 Mhz -func (spi SPI) tx24mhz(tx []byte) { - spi.Bus.DATA.Set(uint32(tx[0])) - device.Asm("nop") - device.Asm("nop") - device.Asm("nop") - device.Asm("nop") - device.Asm("nop") - device.Asm("nop") - - for i := 1; i < len(tx); i++ { - spi.Bus.DATA.Set(uint32(tx[i])) - device.Asm("nop") - device.Asm("nop") - spi.Bus.DATA.Get() - } - for !spi.Bus.INTFLAG.HasBits(sam.SERCOM_SPI_INTFLAG_RXC) { - } - spi.Bus.DATA.Get() -} - -// txrx24mhz is a special tx/rx function for CPU Clock 48 Mhz and SPI Freq 24 Mhz -func (spi SPI) txrx24mhz(tx, rx []byte) { - spi.Bus.DATA.Set(uint32(tx[0])) - device.Asm("nop") - device.Asm("nop") - device.Asm("nop") - device.Asm("nop") - device.Asm("nop") - device.Asm("nop") - - for i := 1; i < len(rx); i++ { - spi.Bus.DATA.Set(uint32(tx[i])) - device.Asm("nop") - device.Asm("nop") - rx[i-1] = byte(spi.Bus.DATA.Get()) - } - for !spi.Bus.INTFLAG.HasBits(sam.SERCOM_SPI_INTFLAG_RXC) { - } - rx[len(rx)-1] = byte(spi.Bus.DATA.Get()) -} - // TCC is one timer/counter peripheral, which consists of a counter and multiple // output channels (that can be connected to actual pins). You can set the // frequency using SetPeriod, but only for all the channels in this TCC |