mirror of
https://github.com/stianeikeland/go-rpio.git
synced 2025-01-23 10:41:03 +01:00
Added SPI documentation (copied from PR)
This commit is contained in:
parent
14a5036b21
commit
0811a9f862
17
README.md
17
README.md
|
@ -71,6 +71,23 @@ rpio.Close()
|
||||||
|
|
||||||
Also see example [examples/blinker/blinker.go](examples/blinker/blinker.go)
|
Also see example [examples/blinker/blinker.go](examples/blinker/blinker.go)
|
||||||
|
|
||||||
|
### SPI
|
||||||
|
|
||||||
|
#### setup/teardown
|
||||||
|
- `rpio.SpiBegin(rpio.Spi0)` has to be called first before using any Spi func. It will change pin modes to `Spi` and initialize default setting.
|
||||||
|
- `rpio.SpiEnd(rpio.Spi0)` should be called at the end, it will switch pin modes to `Input`.
|
||||||
|
|
||||||
|
#### transferring data
|
||||||
|
- `rpio.SpiTransmit(byte)` or `rpio.SpiTransmit(bytes...)` will transmit byte or bytes to slave.
|
||||||
|
- `rpio.SpiReceive(n)` will return n bytes received from slave.
|
||||||
|
- `rpio.SpiExchange(buffer)` will simultaneously transmit data from the buffer to slave and data from slave to the same buffer in full duplex way.
|
||||||
|
|
||||||
|
#### settings
|
||||||
|
- `rpio.SpiSpeed(hz)` will set transmit speed of SPI
|
||||||
|
- `rpio.SpiChipSelect(n)` will select chip/slave (ce0, ce1, or ce2) to which transferring will be done
|
||||||
|
- `rpio.SpiChipSelectPolarity(n, pol)` set chip select polarity (low enabled is used by default which usually works most of the time)
|
||||||
|
- `rpio.SpiMode(cpol, cpha)` set clock/communication mode (=combination of clock polarity and clock phase; cpol=0, cpha=0 is used by default which usually works most of the time)
|
||||||
|
|
||||||
## Other ##
|
## Other ##
|
||||||
|
|
||||||
Currently, it supports basic functionality such as:
|
Currently, it supports basic functionality such as:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user