atsamd21: remove special handling for SPI-24mhz
Этот коммит содержится в:
родитель
8dfefb46d1
коммит
6f61b83ad5
1 изменённых файлов: 12 добавлений и 77 удалений
|
@ -8,7 +8,6 @@
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"device"
|
|
||||||
"device/arm"
|
"device/arm"
|
||||||
"device/sam"
|
"device/sam"
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -1301,27 +1300,6 @@ var (
|
||||||
// spi.Tx(nil, rx)
|
// spi.Tx(nil, rx)
|
||||||
//
|
//
|
||||||
func (spi SPI) Tx(w, r []byte) error {
|
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.tx24mhz(w)
|
|
||||||
|
|
||||||
default:
|
|
||||||
// write/read
|
|
||||||
if len(w) != len(r) {
|
|
||||||
return ErrTxInvalidSliceSize
|
|
||||||
}
|
|
||||||
|
|
||||||
spi.txrx24mhz(w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
switch {
|
switch {
|
||||||
case w == nil:
|
case w == nil:
|
||||||
// read only, so write zero and read a result.
|
// read only, so write zero and read a result.
|
||||||
|
@ -1338,7 +1316,6 @@ func (spi SPI) Tx(w, r []byte) error {
|
||||||
|
|
||||||
spi.txrx(w, r)
|
spi.txrx(w, r)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1390,48 +1367,6 @@ func (spi SPI) txrx(tx, rx []byte) {
|
||||||
rx[len(rx)-1] = byte(spi.Bus.DATA.Get())
|
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
|
// 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
|
// 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
|
// frequency using SetPeriod, but only for all the channels in this TCC
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче