1
0
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:
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" _ "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()

View File

@ -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()