From bb82613c6464897802d04f74ca92cad94d9466ad Mon Sep 17 00:00:00 2001 From: kunalpowar Date: Thu, 22 May 2014 03:14:33 +0530 Subject: [PATCH] spi: code fixes in samples --- samples/mcp3008.go | 11 +++++++---- samples/spimcp3008.go | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/samples/mcp3008.go b/samples/mcp3008.go index 368d9ee..791d56a 100644 --- a/samples/mcp3008.go +++ b/samples/mcp3008.go @@ -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() diff --git a/samples/spimcp3008.go b/samples/spimcp3008.go index 045106c..efff661 100644 --- a/samples/spimcp3008.go +++ b/samples/spimcp3008.go @@ -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()