gobot.io/x/gobot@v1.16.0/drivers/spi/spi_test.go (about)

     1  package spi
     2  
     3  import (
     4  	"periph.io/x/periph/conn"
     5  	"periph.io/x/periph/conn/physic"
     6  	xspi "periph.io/x/periph/conn/spi"
     7  )
     8  
     9  type TestConnector struct{}
    10  
    11  func (ctr *TestConnector) GetSpiConnection(busNum, chipNum, mode, bits int, maxSpeed int64) (device Connection, err error) {
    12  	return NewConnection(&TestSpiConnection{}, &TestSpiDevice{}), nil
    13  }
    14  
    15  func (ctr *TestConnector) GetSpiDefaultBus() int {
    16  	return 0
    17  }
    18  
    19  func (ctr *TestConnector) GetSpiDefaultChip() int {
    20  	return 0
    21  }
    22  
    23  func (ctr *TestConnector) GetSpiDefaultMode() int {
    24  	return 0
    25  }
    26  
    27  func (ctr *TestConnector) GetSpiDefaultBits() int {
    28  	return 0
    29  }
    30  
    31  func (ctr *TestConnector) GetSpiDefaultMaxSpeed() int64 {
    32  	return 0
    33  }
    34  
    35  type TestSpiDevice struct {
    36  	dev Connection
    37  }
    38  
    39  func (c *TestSpiDevice) String() string {
    40  	return "TestSpiDevice"
    41  }
    42  
    43  func (c *TestSpiDevice) Duplex() conn.Duplex {
    44  	return conn.Half
    45  }
    46  
    47  func (c *TestSpiDevice) TxPackets(p []xspi.Packet) error {
    48  	return nil
    49  }
    50  
    51  func (c *TestSpiDevice) Tx(w, r []byte) error {
    52  	return nil
    53  }
    54  
    55  type TestSpiConnection struct {
    56  	conn Operations
    57  }
    58  
    59  func (c *TestSpiConnection) String() string {
    60  	return "TestSpiConnection"
    61  }
    62  
    63  func (c *TestSpiConnection) Close() error {
    64  	return nil
    65  }
    66  
    67  func (c *TestSpiConnection) Connect(maxHz physic.Frequency, mode xspi.Mode, bits int) (xspi.Conn, error) {
    68  	return nil, nil
    69  }
    70  
    71  func (c *TestSpiConnection) LimitSpeed(maxHz physic.Frequency) error {
    72  	return nil
    73  }