1
0
mirror of https://github.com/kidoman/embd synced 2024-12-21 20:30:05 +01:00

spi: code fixes in samples

This commit is contained in:
kunalpowar 2014-05-22 03:14:33 +05:30
parent 5965ddf789
commit bb82613c64
2 changed files with 14 additions and 8 deletions

View File

@ -13,6 +13,13 @@ import (
_ "github.com/kidoman/embd/host/all"
)
const (
channel = 0
speed = 1000000
bpw = 8
delay = 0
)
func main() {
flag.Parse()
fmt.Println("this is a sample code for mcp3008 10bit 8 channel ADC")
@ -22,10 +29,6 @@ func main() {
}
defer embd.CloseSPI()
channel := 0
speed := 1000000
bpw := 8
delay := 0
spiBus := embd.NewSPIBus(embd.SPIMode0, channel, speed, bpw, delay)
defer spiBus.Close()

View File

@ -11,6 +11,13 @@ import (
_ "github.com/kidoman/embd/host/all"
)
const (
channel = 0
speed = 1000000
bpw = 8
delay = 0
)
func main() {
flag.Parse()
if err := embd.InitSPI(); err != nil {
@ -18,10 +25,6 @@ func main() {
}
defer embd.CloseSPI()
channel := 0
speed := 1000000
bpw := 8
delay := 0
bus := embd.NewSPIBus(embd.SPIMode0, channel, speed, bpw, delay)
defer bus.Close()