golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/io/i2c/example_test.go (about)

     1  // Copyright 2016 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package i2c_test
     6  
     7  import (
     8  	"golang.org/x/exp/io/i2c"
     9  )
    10  
    11  func ExampleOpen() {
    12  	d, err := i2c.Open(&i2c.Devfs{Dev: "/dev/i2c-1"}, 0x39)
    13  	if err != nil {
    14  		panic(err)
    15  	}
    16  
    17  	// opens a 10-bit address
    18  	d, err = i2c.Open(&i2c.Devfs{Dev: "/dev/i2c-1"}, i2c.TenBit(0x78))
    19  	if err != nil {
    20  		panic(err)
    21  	}
    22  
    23  	_ = d
    24  }