Last active
November 22, 2021 13:55
-
-
Save deadprogram/06a20962dd2273f20cfcb9ebd163ada7 to your computer and use it in GitHub Desktop.
Concept for i2c peripheral (target) interface
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
package main | |
import ( | |
"machine" | |
"time" | |
) | |
var input [16]byte | |
func main() { | |
machine.I2C0.Configure(machine.I2CConfig{ | |
// valid options are machine.I2CController or machine.I2CPeripheral | |
Mode: machine.I2CPeripheral, | |
Address: 0x84, | |
}) | |
for { | |
if machine.I2C0.Buffered() { | |
n, _ := machine.I2C0.Read(input[:]) | |
machine.I2C0.Write([]byte("hello, ")) | |
machine.I2C0.Write(input[:n]) | |
machine.I2C0.Write([]byte("\r\n")) | |
} | |
time.Sleep(10 * time.Millisecond) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment