mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
refactor: use *SPI everywhere to make consistant for implementations.
Fixes #4663 "in reverse" by making SPI a pointer everywhere, as discussed in the comments. Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -114,7 +114,7 @@ func freqToClockDiv(hz uint32) uint32 {
|
||||
}
|
||||
|
||||
// Configure and make the SPI peripheral ready to use.
|
||||
func (spi SPI) Configure(config SPIConfig) error {
|
||||
func (spi *SPI) Configure(config SPIConfig) error {
|
||||
// right now this is only setup to work for the esp32c3 spi2 bus
|
||||
if spi.Bus != esp.SPI2 {
|
||||
return ErrInvalidSPIBus
|
||||
@@ -216,7 +216,7 @@ func (spi SPI) Configure(config SPIConfig) error {
|
||||
|
||||
// Transfer writes/reads a single byte using the SPI interface. If you need to
|
||||
// transfer larger amounts of data, Tx will be faster.
|
||||
func (spi SPI) Transfer(w byte) (byte, error) {
|
||||
func (spi *SPI) Transfer(w byte) (byte, error) {
|
||||
spi.Bus.SetMS_DLEN_MS_DATA_BITLEN(7)
|
||||
|
||||
spi.Bus.SetW0(uint32(w))
|
||||
@@ -238,7 +238,7 @@ func (spi SPI) Transfer(w byte) (byte, error) {
|
||||
// interface, there must always be the same number of bytes written as bytes read.
|
||||
// This is accomplished by sending zero bits if r is bigger than w or discarding
|
||||
// the incoming data if w is bigger than r.
|
||||
func (spi SPI) Tx(w, r []byte) error {
|
||||
func (spi *SPI) Tx(w, r []byte) error {
|
||||
toTransfer := len(w)
|
||||
if len(r) > toTransfer {
|
||||
toTransfer = len(r)
|
||||
|
||||
Reference in New Issue
Block a user