From 7531d3f42a0ef16d4af47c900eea7764f78dfaa2 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Ruel Date: Sun, 11 Nov 2018 16:55:34 -0500 Subject: [PATCH] bitbang: make i2c use physic.Frequency It's not working yet so it's not like it's super useful, doing this for consistency. --- experimental/devices/bitbang/i2c.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/experimental/devices/bitbang/i2c.go b/experimental/devices/bitbang/i2c.go index 3a647f0..cd62f5c 100644 --- a/experimental/devices/bitbang/i2c.go +++ b/experimental/devices/bitbang/i2c.go @@ -33,7 +33,7 @@ const SkipAddr uint16 = 0xFFFF // - Special address SkipAddr can be used to skip the address from being // communicated // - An arbitrary speed can be used -func New(clk gpio.PinIO, data gpio.PinIO, speedHz int) (*I2C, error) { +func New(clk gpio.PinIO, data gpio.PinIO, f physic.Frequency) (*I2C, error) { // Spec calls to idle at high. Page 8, section 3.1.1. // Set SCL as pull-up. if err := clk.In(gpio.PullUp, gpio.NoEdge); err != nil { @@ -52,7 +52,7 @@ func New(clk gpio.PinIO, data gpio.PinIO, speedHz int) (*I2C, error) { i := &I2C{ scl: clk, sda: data, - halfCycle: time.Second / time.Duration(speedHz) / time.Duration(2), + halfCycle: f.Duration() / 2, } return i, nil }