github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/spi.go (about)

     1  //go:build !baremetal || atmega || esp32 || fe310 || k210 || nrf || (nxp && !mk66f18) || rp2040 || sam || (stm32 && !stm32f7x2 && !stm32l5x2)
     2  
     3  package machine
     4  
     5  import "errors"
     6  
     7  // SPI phase and polarity configs CPOL and CPHA
     8  const (
     9  	Mode0 = 0
    10  	Mode1 = 1
    11  	Mode2 = 2
    12  	Mode3 = 3
    13  )
    14  
    15  var (
    16  	ErrTxInvalidSliceSize      = errors.New("SPI write and read slices must be same size")
    17  	errSPIInvalidMachineConfig = errors.New("SPI port was not configured properly by the machine")
    18  )
    19  
    20  // If you are getting a compile error on this line please check to see you've
    21  // correctly implemented the methods on the SPI type. They must match
    22  // the interface method signatures type to type perfectly.
    23  // If not implementing the SPI type please remove your target from the build tags
    24  // at the top of this file.
    25  var _ interface { // 2
    26  	Configure(config SPIConfig) error
    27  	Tx(w, r []byte) error
    28  	Transfer(w byte) (byte, error)
    29  } = (*SPI)(nil)