diff --git a/samples/spimcp3008.go b/samples/spimcp3008.go index 0f2419b..e35b09d 100644 --- a/samples/spimcp3008.go +++ b/samples/spimcp3008.go @@ -16,9 +16,10 @@ func main() { if err := embd.InitSPI(); err != nil { panic(err) } + defer embd.CloseSPI() bus := embd.NewSPIBus(embd.SpiMode0, 0, 1000000, 8, 0) - defer clean(bus) + defer bus.Close() for i := 0; i < 30; i++ { time.Sleep(1 * time.Second) @@ -28,11 +29,6 @@ func main() { } -func clean(bus embd.SPIBus) { - bus.Close() - embd.CloseSPI() -} - func getSensorValue(bus embd.SPIBus) (uint16, error) { data := make([]uint8, 3) data[0] = 1