machine: add dummy async SPI methods

This prepares all devices for actual async SPI support.
This commit is contained in:
Ayke van Laethem
2023-11-04 16:14:47 +01:00
parent 174d492355
commit 24d718fa05
2 changed files with 32 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
//go:build !baremetal || atmega || esp32 || fe310 || k210 || nrf || (nxp && !mk66f18) || rp2040 || sam || (stm32 && !stm32f7x2 && !stm32l5x2)
package machine
// This is a non-async implementation of the async SPI calls.
// It is useful for devices that don't support DMA on SPI, or for which it
// hasn't been implemented yet.
// IsAsync returns whether the SPI supports async operation (usually DMA).
//
// This SPI does not support async operations.
func (s SPI) IsAsync() bool {
return false
}
// Start a transfer in the background.
//
// Because this SPI implementation doesn't support async operation, it is an
// alias for Tx.
func (s SPI) StartTx(tx, rx []byte) error {
return s.Tx(tx, rx)
}
// Wait until all active transactions (started by StartTx) have finished.
//
// This is a no-op on this SPI implementation.
func (s SPI) Wait() error {
return nil
}
+3
View File
@@ -26,4 +26,7 @@ var _ interface { // 2
Configure(config SPIConfig) error
Tx(w, r []byte) error
Transfer(w byte) (byte, error)
IsAsync() bool
StartTx(tx, rx []byte) error
Wait() error
} = (*SPI)(nil)