mirror of
https://github.com/kidoman/embd
synced 2024-12-22 12:50:19 +01:00
spi: code fixes in samples
This commit is contained in:
parent
5965ddf789
commit
bb82613c64
@ -13,6 +13,13 @@ import (
|
|||||||
_ "github.com/kidoman/embd/host/all"
|
_ "github.com/kidoman/embd/host/all"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
channel = 0
|
||||||
|
speed = 1000000
|
||||||
|
bpw = 8
|
||||||
|
delay = 0
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("this is a sample code for mcp3008 10bit 8 channel ADC")
|
fmt.Println("this is a sample code for mcp3008 10bit 8 channel ADC")
|
||||||
@ -22,10 +29,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer embd.CloseSPI()
|
defer embd.CloseSPI()
|
||||||
|
|
||||||
channel := 0
|
|
||||||
speed := 1000000
|
|
||||||
bpw := 8
|
|
||||||
delay := 0
|
|
||||||
spiBus := embd.NewSPIBus(embd.SPIMode0, channel, speed, bpw, delay)
|
spiBus := embd.NewSPIBus(embd.SPIMode0, channel, speed, bpw, delay)
|
||||||
defer spiBus.Close()
|
defer spiBus.Close()
|
||||||
|
|
||||||
|
@ -11,6 +11,13 @@ import (
|
|||||||
_ "github.com/kidoman/embd/host/all"
|
_ "github.com/kidoman/embd/host/all"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
channel = 0
|
||||||
|
speed = 1000000
|
||||||
|
bpw = 8
|
||||||
|
delay = 0
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if err := embd.InitSPI(); err != nil {
|
if err := embd.InitSPI(); err != nil {
|
||||||
@ -18,10 +25,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer embd.CloseSPI()
|
defer embd.CloseSPI()
|
||||||
|
|
||||||
channel := 0
|
|
||||||
speed := 1000000
|
|
||||||
bpw := 8
|
|
||||||
delay := 0
|
|
||||||
bus := embd.NewSPIBus(embd.SPIMode0, channel, speed, bpw, delay)
|
bus := embd.NewSPIBus(embd.SPIMode0, channel, speed, bpw, delay)
|
||||||
defer bus.Close()
|
defer bus.Close()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user