mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-04 23:17:47 +00:00
i2csoft: add source code for each target
This commit is contained in:
@@ -4,20 +4,14 @@
|
||||
package i2csoft
|
||||
|
||||
import (
|
||||
"device/arm"
|
||||
"device"
|
||||
)
|
||||
|
||||
// wait waits for half the time of the SCL operation interval. It is set to
|
||||
// about 100 kHz.
|
||||
func (i2c *I2C) wait() {
|
||||
// atsamd51
|
||||
// 1 : about 388kHz
|
||||
// 17 : about 97kHz
|
||||
|
||||
wait := 1
|
||||
if i2c.baudrate < 400*1e3 {
|
||||
wait = 17
|
||||
}
|
||||
|
||||
wait := 20
|
||||
for i := 0; i < wait; i++ {
|
||||
arm.Asm(`nop`)
|
||||
device.Asm(`nop`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,10 @@ import (
|
||||
"device"
|
||||
)
|
||||
|
||||
// wait waits for half the time of the SCL operation interval. It is set to
|
||||
// about 100 kHz.
|
||||
func (i2c *I2C) wait() {
|
||||
// atsamd51
|
||||
// 10 : about 387kHz
|
||||
// 56 : about 99kHz
|
||||
|
||||
wait := 10
|
||||
if i2c.baudrate < 400*1e3 {
|
||||
wait = 56
|
||||
}
|
||||
|
||||
wait := 60
|
||||
for i := 0; i < wait; i++ {
|
||||
device.Asm(`nop`)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build nrf52840
|
||||
// +build nrf52840
|
||||
|
||||
package i2csoft
|
||||
|
||||
import (
|
||||
"device"
|
||||
)
|
||||
|
||||
// wait waits for half the time of the SCL operation interval. It is set to
|
||||
// about 100 kHz.
|
||||
func (i2c *I2C) wait() {
|
||||
wait := 26
|
||||
for i := 0; i < wait; i++ {
|
||||
device.Asm(`nop`)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//go:build !esp32 && !atsamd51 && !atsame5x
|
||||
// +build !esp32,!atsamd51,!atsame5x
|
||||
//go:build !esp32 && !atsamd51 && !atsame5x && !stm32f4 && !rp2040 && ! nrf52840
|
||||
// +build !esp32,!atsamd51,!atsame5x,!stm32f4,!rp2040,!nrf52840
|
||||
|
||||
package i2csoft
|
||||
|
||||
@@ -7,15 +7,9 @@ import (
|
||||
"device"
|
||||
)
|
||||
|
||||
// wait waits for half the time of the SCL operation interval.
|
||||
func (i2c *I2C) wait() {
|
||||
// atsamd21 @ 48MHz
|
||||
// 1 : about 360kHz
|
||||
// 24 : about 96kHz
|
||||
wait := 1
|
||||
if i2c.baudrate < 400*1e3 {
|
||||
wait = 19
|
||||
}
|
||||
|
||||
wait := 20
|
||||
for i := 0; i < wait; i++ {
|
||||
device.Asm(`nop`)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build rp2040
|
||||
// +build rp2040
|
||||
|
||||
package i2csoft
|
||||
|
||||
import (
|
||||
"device"
|
||||
)
|
||||
|
||||
// wait waits for half the time of the SCL operation interval. It is set to
|
||||
// about 100 kHz.
|
||||
func (i2c *I2C) wait() {
|
||||
wait := 50
|
||||
for i := 0; i < wait; i++ {
|
||||
device.Asm(`nop`)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build stm32f4
|
||||
// +build stm32f4
|
||||
|
||||
package i2csoft
|
||||
|
||||
import (
|
||||
"device"
|
||||
)
|
||||
|
||||
// wait waits for half the time of the SCL operation interval. It is set to
|
||||
// about 100 kHz.
|
||||
func (i2c *I2C) wait() {
|
||||
wait := 77
|
||||
for i := 0; i < wait; i++ {
|
||||
device.Asm(`nop`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user