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:
deadprogram
2025-02-25 11:09:14 +01:00
committed by Ron Evans
parent cab3834bc9
commit 2bee29959b
31 changed files with 99 additions and 101 deletions
+3 -3
View File
@@ -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)