Created
April 4, 2022 19:06
-
-
Save deadprogram/6e1f3ecdb79cf223db2fdaeb4534bfe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NUCLEO-L432KC | |
// GND to GND | |
// SCL to D5 | |
// SDA to D4 | |
package main | |
import ( | |
"fmt" | |
"machine" | |
"time" | |
) | |
func main() { | |
machine.I2C0.Configure(machine.I2CConfig{}) | |
led := machine.LED | |
led.Configure(machine.PinConfig{Mode: machine.PinOutput}) | |
if true { | |
for { | |
fmt.Printf("\r\n 0 1 2 3 4 5 6 7 8 9 A B C D E F") | |
fmt.Printf("\r\n") | |
for y := uint16(0); y < 0x8; y++ { | |
led.Low() | |
time.Sleep(time.Millisecond * 200) | |
fmt.Printf("\r%02x", y*0x10) | |
for x := uint16(0); x < 0x10; x++ { | |
i2caddr := y*0x10 + x | |
err := machine.I2C0.Tx(i2caddr, []byte{0}, nil) | |
if err == nil { | |
fmt.Printf(" %02x", i2caddr) | |
} else { | |
fmt.Print(" --") | |
} | |
led.High() | |
time.Sleep(100 * time.Millisecond) | |
} | |
fmt.Println("") | |
} | |
fmt.Println("") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modularized i2cscanner: