i2csoft: add support for software I2C

This commit is contained in:
sago35
2021-09-22 23:31:02 +09:00
committed by Ron Evans
parent 94729a4f7d
commit bd42656644
7 changed files with 396 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
//go:build atsamd51 || atsame5x
// +build atsamd51 atsame5x
package i2csoft
import (
"device/arm"
)
func (i2c *I2C) wait() {
// atsamd51
// 1 : about 388kHz
// 17 : about 97kHz
wait := 1
if i2c.baudrate < 400*1e3 {
wait = 17
}
for i := 0; i < wait; i++ {
arm.Asm(`nop`)
}
}