| 1 | // Copyright 2016 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | //go:build !linux |
| 6 | |
| 7 | package spi |
| 8 | |
| 9 | import ( |
| 10 | "errors" |
| 11 | |
| 12 | "golang.org/x/exp/io/spi/driver" |
| 13 | ) |
| 14 | |
| 15 | // Devfs is a no-implementation of an SPI driver that works against the devfs. |
| 16 | // You need to have loaded the Linux "spidev" module to use this driver. |
| 17 | type Devfs struct { |
| 18 | // Dev is the device to be opened. |
| 19 | // Device name is usually in the /dev/spidev<bus>.<chip> format. |
| 20 | // Required. |
| 21 | Dev string |
| 22 | |
| 23 | // Mode is the SPI mode. SPI mode is a combination of polarity and phases. |
| 24 | // CPOL is the high order bit, CPHA is the low order. Pre-computed mode |
| 25 | // values are Mode0, Mode1, Mode2 and Mode3. The value of the mode argument |
| 26 | // can be overridden by the device's driver. |
| 27 | // Required. |
| 28 | Mode Mode |
| 29 | |
| 30 | // MaxSpeed is the max clock speed (Hz) and can be overridden by the device's driver. |
| 31 | // Required. |
| 32 | MaxSpeed int64 |
| 33 | } |
| 34 | |
| 35 | // Open opens the provided device with the speicifed options |
| 36 | // and returns a connection. |
| 37 | func (d *Devfs) Open() (driver.Conn, error) { |
| 38 | return nil, errors.New("not implemented on this platform") |
| 39 | } |